mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
Merge pull request #565 from rustic-rs/restore-existing
restore: Treat all existing contents correctly
This commit is contained in:
commit
75985f1626
@ -100,8 +100,19 @@ impl Node {
|
||||
self.node_type == NodeType::Dir
|
||||
}
|
||||
|
||||
pub fn is_symlink(&self) -> bool {
|
||||
matches!(self.node_type, NodeType::Symlink { linktarget: _ })
|
||||
pub fn is_file(&self) -> bool {
|
||||
matches!(self.node_type, NodeType::File)
|
||||
}
|
||||
|
||||
pub fn is_special(&self) -> bool {
|
||||
matches!(
|
||||
self.node_type,
|
||||
NodeType::Symlink { linktarget: _ }
|
||||
| NodeType::Dev { device: _ }
|
||||
| NodeType::Chardev { device: _ }
|
||||
| NodeType::Fifo
|
||||
| NodeType::Socket
|
||||
)
|
||||
}
|
||||
|
||||
pub fn set_subtree(&mut self, id: Id) {
|
||||
|
||||
@ -302,8 +302,9 @@ fn allocate_and_collect(
|
||||
}
|
||||
Ordering::Equal => {
|
||||
// process existing node
|
||||
if node.is_dir() != dst.file_type().unwrap().is_dir()
|
||||
|| (node.is_symlink() != dst.file_type().unwrap().is_symlink())
|
||||
if (node.is_dir() && !dst.file_type().unwrap().is_dir())
|
||||
|| (node.is_file() && !dst.metadata().unwrap().is_file())
|
||||
|| node.is_special()
|
||||
{
|
||||
// if types do not match, first remove the existing file
|
||||
process_existing(dst)?;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user