From c3a9250079cf6dfcec886623daa72fc895e8896a Mon Sep 17 00:00:00 2001 From: Oliver Breitwieser Date: Sat, 27 Mar 2021 18:32:58 +0100 Subject: [PATCH] Disable --expire via 'none' --- CHANGELOG.md | 14 +++++++++----- example-config/asfa/hosts/my-remote-site-2.yaml | 1 + src/cmd/push.rs | 9 ++++++++- tests/simple-file-upload.rs | 2 +- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30f5a27..e951f87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,15 @@ * `push`-command: * Remove need to seperate single alias from single file by dashes if alias specified first. - Previously: `asfa push --alias my-alias.txt -- my-original-file.txt` - Now: `asfa push --alias my-alias.txt my-original-file.txt` - * Check response for errors regaring `atd` not running if `--expire` specified. - * Now supports a default setting for `--expire` in the config. Same as auth, - both a global setting and host-specific settings are supported. + Previously: `asfa push --alias my-alias.txt -- my-original-file.txt` Now: + `asfa push --alias my-alias.txt my-original-file.txt` + * Check response for errors regaring `atd` not running if `--expire` + specified. + * Now supports a default setting for `--expire` in the config. + * Same as auth, both a global setting and host-specific settings are + supported. + * Any set default argument can be disabled per host or command line by + specifying `none` as argument. * `list`: * More informative message if no files are present on remote site. * tests: diff --git a/example-config/asfa/hosts/my-remote-site-2.yaml b/example-config/asfa/hosts/my-remote-site-2.yaml index 3692160..d9fad46 100644 --- a/example-config/asfa/hosts/my-remote-site-2.yaml +++ b/example-config/asfa/hosts/my-remote-site-2.yaml @@ -3,6 +3,7 @@ # * port will be inferred form openSSH and defaults to 22 otherwise hostname: my-hostname-2.eu folder: /var/www/default/asfa +expire: none # Disable a potentially set default setting url: https://my-domain-2.eu/asfa group: www-data auth: # optional, overwrites global auth-config diff --git a/src/cmd/push.rs b/src/cmd/push.rs index 1bfee4e..f60ed1d 100644 --- a/src/cmd/push.rs +++ b/src/cmd/push.rs @@ -32,6 +32,8 @@ pub struct Push { /// Mininum time till expiration is a minute. /// /// Any setting specified via command line overwrites any settings from config files. + /// + /// A globally set expiration setting can overwritten by specifying "none". #[clap(short, long)] expire: Option, @@ -97,7 +99,12 @@ impl Push { .as_ref() .or_else(|| session.host.expire.as_ref()) { - Some(At::new(session, &delay)?) + // Allow for explicit disabling term that overwrites a possibly set default + if ["no", "none", "disabled", "false"].contains(&delay.as_str()) { + None + } else { + Some(At::new(session, &delay)?) + } } else { None }; diff --git a/tests/simple-file-upload.rs b/tests/simple-file-upload.rs index bc1b00f..ea3d2db 100644 --- a/tests/simple-file-upload.rs +++ b/tests/simple-file-upload.rs @@ -21,7 +21,7 @@ fn simple_file_upload(host: &str) -> Result<()> { let hash_b64 = base64::encode_config(hex::decode(hash)?, base64::URL_SAFE); run_cmd(format!( - "cargo run -- --loglevel debug -H {} push {} --alias {}", + "cargo run -- --loglevel debug -H {} push {} --alias {} --expire none", host, local.display(), alias