Skip to content

Commit

Permalink
Disable --expire via 'none'
Browse files Browse the repository at this point in the history
  • Loading branch information
obreitwi committed Mar 27, 2021
1 parent 29a1c9c commit c3a9250
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions example-config/asfa/hosts/my-remote-site-2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/cmd/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

Expand Down Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion tests/simple-file-upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c3a9250

Please sign in to comment.