Skip to content

Commit

Permalink
fix: upserting operation should handle deleting in edge cases where t…
Browse files Browse the repository at this point in the history
…he source and target URNs are different (#1737)
  • Loading branch information
sxyazi authored Oct 6, 2024
1 parent 87b159f commit dcbe787
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 4 additions & 0 deletions yazi-fs/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ impl Files {
return;
}

self.update_deleting(
files.iter().filter(|&(u, f)| u != f.urn()).map(|(_, f)| f.urn_owned()).collect(),
);

let (hidden, items) = self.update_updating(files);
if hidden.is_empty() && items.is_empty() {
return;
Expand Down
11 changes: 5 additions & 6 deletions yazi-shared/src/fs/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ impl FilesOp {
}

pub fn rename(map: HashMap<Url, File>) {
let mut parents = HashMap::new();
let mut parents: HashMap<_, (HashSet<_>, HashMap<_, _>)> = Default::default();
for (o, n) in map {
let Some(o_p) = o.parent_url() else { continue };
if o == n.url {
parents.entry(o_p).or_insert((HashSet::new(), HashMap::new())).1.insert(o.urn_owned(), n);
} else if let Some(n_p) = n.url.parent_url() {
parents.entry(o_p).or_insert((HashSet::new(), HashMap::new())).0.insert(o.urn_owned());
parents.entry(n_p).or_insert((HashSet::new(), HashMap::new())).1.insert(n.urn_owned(), n);
let Some(n_p) = n.url.parent_url() else { continue };
if o_p != n_p {
parents.entry(o_p).or_default().0.insert(o.urn_owned());
}
parents.entry(n_p).or_default().1.insert(n.urn_owned(), n);
}
for (p, (o, n)) in parents {
match (o.is_empty(), n.is_empty()) {
Expand Down

0 comments on commit dcbe787

Please sign in to comment.