From 8767afa0638edc4d3a8995dc96ebfeb6703fc6a5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 7 Dec 2020 16:32:48 +0100 Subject: Make sources named This patch changes the sources to be named. This is required for nice interpolation when layering pkg.toml files. Before this, we had to make sure that the `[[sources]]` array element was on the right position. For example, consider two files: /pkg.toml /package/pkg.toml in the first: [[sources]] url = "some/thing" in the second: [[sources] hash.type = "sha1" hash.value = "asdf..." When merged: [[sources] url = "some/thing" hash.type = "sha1" hash.value = "asdf..." but because the _position_ was responsible for merging these elements, adding a new source file _before_ the existing on in /pkg.toml would yield the /package/pkg.toml incomplete when merged onto /pkg.toml, thus resulting in an error. With named source entries, this is less likely. The source file name includes the source name as well, of course. Signed-off-by: Matthias Beyer --- src/source/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/source') diff --git a/src/source/mod.rs b/src/source/mod.rs index 1117a55..34b4043 100644 --- a/src/source/mod.rs +++ b/src/source/mod.rs @@ -29,24 +29,26 @@ pub struct SourceEntry { cache_root: PathBuf, package_name: PackageName, package_version: PackageVersion, + package_source_name: String, package_source: Source, } impl SourceEntry { fn source_file_path(&self) -> PathBuf { - self.cache_root.join(format!("{}-{}/{}.source", self.package_name, self.package_version, self.package_source.hash().value())) + self.cache_root.join(format!("{}-{}/{}-{}.source", self.package_name, self.package_version, self.package_source_name, self.package_source.hash().value())) } fn for_package(cache_root: PathBuf, package: &Package) -> Vec { package.sources() .clone() .into_iter() - .map(|source| { + .map(|(source_name, source)| { SourceEntry { cache_root: cache_root.clone(), package_name: package.name().clone(), package_version: package.version().clone(), + package_source_name: source_name, package_source: source, } }) -- cgit v1.2.3