diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-07 16:32:48 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-07 16:54:26 +0100 |
commit | 8767afa0638edc4d3a8995dc96ebfeb6703fc6a5 (patch) | |
tree | 033be4ef1353bfeb8bbf0a4b4cb8f3a26925405f /src/source | |
parent | 6d5b427fda5a74a7c0302e892a23b5229fc18dea (diff) |
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 <mail@beyermatthias.de>
Diffstat (limited to 'src/source')
-rw-r--r-- | src/source/mod.rs | 6 |
1 files changed, 4 insertions, 2 deletions
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<Self> { 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, } }) |