mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-21 15:51:43 +03:00
fix: upserting operation should handle deleting in edge cases where the source and target URNs are different (#1737)
This commit is contained in:
parent
87b159fb9d
commit
dcbe7873cd
@ -301,6 +301,10 @@ impl Files {
|
|||||||
return;
|
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);
|
let (hidden, items) = self.update_updating(files);
|
||||||
if hidden.is_empty() && items.is_empty() {
|
if hidden.is_empty() && items.is_empty() {
|
||||||
return;
|
return;
|
||||||
|
@ -48,15 +48,14 @@ impl FilesOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn rename(map: HashMap<Url, File>) {
|
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 {
|
for (o, n) in map {
|
||||||
let Some(o_p) = o.parent_url() else { continue };
|
let Some(o_p) = o.parent_url() else { continue };
|
||||||
if o == n.url {
|
let Some(n_p) = n.url.parent_url() else { continue };
|
||||||
parents.entry(o_p).or_insert((HashSet::new(), HashMap::new())).1.insert(o.urn_owned(), n);
|
if o_p != n_p {
|
||||||
} else if let Some(n_p) = n.url.parent_url() {
|
parents.entry(o_p).or_default().0.insert(o.urn_owned());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
parents.entry(n_p).or_default().1.insert(n.urn_owned(), n);
|
||||||
}
|
}
|
||||||
for (p, (o, n)) in parents {
|
for (p, (o, n)) in parents {
|
||||||
match (o.is_empty(), n.is_empty()) {
|
match (o.is_empty(), n.is_empty()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user