Really fix uploading wrong file in replace actions
This commit is contained in:
parent
3aa326e737
commit
75368d4c0c
12
src/main.rs
12
src/main.rs
@ -259,7 +259,7 @@ fn main() -> Result<(), String> {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|file| {
|
.map(|file| {
|
||||||
FileNameInfo::try_from(file.clone())
|
FileNameInfo::try_from(file.clone())
|
||||||
.map(|info| (PathBuf::from(&file), info))
|
.map(|info| (file.clone(), info))
|
||||||
.map_err(|e| format!("Bad file '{}': {e}", file.to_string_lossy()))
|
.map_err(|e| format!("Bad file '{}': {e}", file.to_string_lossy()))
|
||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>()?
|
.collect::<Result<Vec<_>, _>>()?
|
||||||
@ -387,12 +387,12 @@ fn main() -> Result<(), String> {
|
|||||||
let mut actions = present_file_names
|
let mut actions = present_file_names
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|file| file_matcher.matches(file))
|
.filter(|file| file_matcher.matches(file))
|
||||||
.map(|file| {
|
.map(|present_file| {
|
||||||
//special case -> file has the same name as current file, then we just need to replace it
|
//special case -> file has the same name as current file, then we just need to replace it
|
||||||
if *file == file_name {
|
if *present_file == file_name {
|
||||||
FileAction::new(file, Action::Replace).expect("path points to file")
|
FileAction::new(file, Action::Replace).expect("path points to file")
|
||||||
} else {
|
} else {
|
||||||
FileAction::new(file, Action::Delete).expect("path points to file")
|
FileAction::new(present_file, Action::Delete).expect("path points to file")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
@ -421,6 +421,10 @@ fn main() -> Result<(), String> {
|
|||||||
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 {
|
||||||
log!(logger, "{server_actions}");
|
log!(logger, "{server_actions}");
|
||||||
|
log!(logger, debug, "Detailed file actions: ");
|
||||||
|
for file_action in &server_actions.actions {
|
||||||
|
log!(logger, debug, "{file_action:?}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !no_confirm {
|
if !no_confirm {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user