Compare commits

..

No commits in common. "93eed1dc7fe3913e809e29fa4f80c5ed6a03626e" and "1633636cabe4390b770aa24ac3873b77ed2ec0ee" have entirely different histories.

View File

@ -75,7 +75,7 @@ enum Command {
#[arg(short = 'a', long, default_value = "delete", default_missing_value = "archive", num_args = 0..=1)] #[arg(short = 'a', long, default_value = "delete", default_missing_value = "archive", num_args = 0..=1)]
old_version_policy: OldVersionPolicy, old_version_policy: OldVersionPolicy,
/// The directory where to upload to, relative to the server directory /// The directory where to upload to, relative to the server directory
#[arg(short = 'd', long, default_value = "plugins")] #[arg(short = 'p', long, default_value = "plugins")]
upload_directory: PathBuf, upload_directory: PathBuf,
/// Skip the confirmation dialog /// Skip the confirmation dialog
#[arg(long, default_value = "false")] #[arg(long, default_value = "false")]
@ -83,9 +83,6 @@ enum Command {
/// The prefix of the name of older versions of the file, which should be replaced or deleted /// The prefix of the name of older versions of the file, which should be replaced or deleted
#[arg(short, long)] #[arg(short, long)]
file_name: Option<String>, file_name: Option<String>,
/// Only upload files which are not present yet on the target server
#[arg(short, long, default_value = "false")]
pure: bool,
}, },
/// Execute a command on the servers /// Execute a command on the servers
#[command(visible_short_flag_alias = 'c')] #[command(visible_short_flag_alias = 'c')]
@ -189,7 +186,6 @@ fn main() -> Result<(), String> {
mut upload_directory, mut upload_directory,
no_confirm, no_confirm,
file_name, file_name,
pure,
} => { } => {
require_non_empty_servers(&servers)?; require_non_empty_servers(&servers)?;
require_non_empty(&files, "files to upload")?; require_non_empty(&files, "files to upload")?;
@ -308,20 +304,13 @@ fn main() -> Result<(), String> {
let add_action = FileAction::new(file, Action::Add).expect("path points to file"); let add_action = FileAction::new(file, Action::Add).expect("path points to file");
let mut ls_lines = ls_output.lines(); let mut ls_lines = ls_output.lines();
if pure && ls_lines.clone().any(|file| file == file_name) {
log!(logger, debug, "file is already present: {}", file_name);
return vec![]; //ignore that file, since it is already present
}
match old_version_policy { match old_version_policy {
OldVersionPolicy::Ignore => { OldVersionPolicy::Ignore => {
if !ls_lines.any(|file| file == file_name) { vec![if ls_lines.any(|file| file == file_name) {
vec![add_action] //file doesn't exist yet FileAction::new(&file_name, Action::Replace).expect("path points to file")
} else { } else {
vec![FileAction::new(&file_name, Action::Replace) add_action
.expect("path points to file")] }]
}
} }
OldVersionPolicy::Archive => ls_lines OldVersionPolicy::Archive => ls_lines
.filter(|file| file_matcher.matches(file)) .filter(|file| file_matcher.matches(file))
@ -358,15 +347,7 @@ fn main() -> Result<(), String> {
working_directory, working_directory,
}) })
}) })
.collect::<Result<Vec<_>, String>>()? .collect::<Result<Vec<_>, String>>()?;
.into_iter()
.filter(|server_actions| !server_actions.actions.is_empty())
.collect::<Vec<_>>();
if actions.is_empty() {
log!(logger, "Nothing to be done, everything is up to date");
return Ok(())
}
log!(logger, "The following actions will be performed: "); log!(logger, "The following actions will be performed: ");
for server_actions in &actions { for server_actions in &actions {