Use replace action instead of explicit delete action where possible
This commit is contained in:
parent
4f08fabd34
commit
9e8214d742
23
src/main.rs
23
src/main.rs
@ -161,14 +161,29 @@ fn main() -> Result<(), String> {
|
|||||||
})
|
})
|
||||||
.chain(once(add_action))
|
.chain(once(add_action))
|
||||||
.collect(),
|
.collect(),
|
||||||
OldVersionPolicy::Delete => files
|
OldVersionPolicy::Delete => {
|
||||||
|
let mut actions: Vec<_> = files
|
||||||
.filter(|file| file_matcher.matches(file))
|
.filter(|file| file_matcher.matches(file))
|
||||||
.map(|file| FileAction {
|
.map(|file| {
|
||||||
|
//special case -> file has the same name as current file, then we just need to replace it
|
||||||
|
if file == file_name {
|
||||||
|
FileAction {
|
||||||
|
file: PathBuf::from(file),
|
||||||
|
kind: Action::Replace,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
FileAction {
|
||||||
file: PathBuf::from(file),
|
file: PathBuf::from(file),
|
||||||
kind: Action::Delete,
|
kind: Action::Delete,
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.chain(once(add_action))
|
.collect();
|
||||||
.collect(),
|
if !actions.iter().any(|action| action.kind == Action::Replace) {
|
||||||
|
actions.push(add_action);
|
||||||
|
}
|
||||||
|
actions
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user