summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-01-11 10:44:35 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-01-15 23:21:39 +0100
commitf02b9fa526ed3c360fc2a3b3f6a646f3cd0db0b0 (patch)
tree7eb004be462fbad47750f5e97b470083f5556abc
parentf330587fec0cdf2f041531d5e7aea1e4f525e11b (diff)
Add feature to mark a source entry as manual download
This patch adds a feature where a source entry in a package can be marked for manual download. This gives us the ability to mask downloads which are hidden behind cruel JavaScript bullshit bloat where a `curl` cannot access the remote file. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--examples/packages/1/repo/pkg.toml1
-rw-r--r--src/commands/source.rs7
-rw-r--r--src/package/source.rs2
-rw-r--r--src/source/mod.rs4
4 files changed, 14 insertions, 0 deletions
diff --git a/examples/packages/1/repo/pkg.toml b/examples/packages/1/repo/pkg.toml
index a752855..1ad8345 100644
--- a/examples/packages/1/repo/pkg.toml
+++ b/examples/packages/1/repo/pkg.toml
@@ -6,6 +6,7 @@ patches = []
[sources.src]
hash.type = "sha1"
+download_manually = false
[dependencies]
build = []
diff --git a/src/commands/source.rs b/src/commands/source.rs
index 3ec11d5..efb45bc 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -167,6 +167,13 @@ pub async fn download(matches: &ArgMatches, config: &Configuration, repo: Reposi
let bar = multi.add(progressbars.spinner());
bar.set_message(&format!("Downloading {}", source.url()));
async move {
+ if !source.exists() && source.download_manually() {
+ return Err(anyhow!("Cannot download source that is marked for manual download"))
+ .context(anyhow!("Creating source: {}", source.path().display()))
+ .context(anyhow!("Downloading source: {}", source.url()))
+ .map_err(Error::from)
+ }
+
if source.exists() && !force {
Err(anyhow!("Source exists: {}", source.path().display()))
} else {
diff --git a/src/package/source.rs b/src/package/source.rs
index 9584803..667a9f7 100644
--- a/src/package/source.rs
+++ b/src/package/source.rs
@@ -22,6 +22,8 @@ pub struct Source {
url: Url,
#[getset(get = "pub")]
hash: SourceHash,
+ #[getset(get = "pub")]
+ download_manually: bool,
}
impl Source {
diff --git a/src/source/mod.rs b/src/source/mod.rs
index 295d7a9..fac7dce 100644
--- a/src/source/mod.rs
+++ b/src/source/mod.rs
@@ -84,6 +84,10 @@ impl SourceEntry {
self.package_source.url()
}
+ pub fn download_manually(&self) -> bool {
+ *self.package_source.download_manually()
+ }
+
pub async fn remove_file(&self) -> Result<()> {
let p = self.source_file_path();
tokio::fs::remove_file(&p).await?;