mirror of https://github.com/dswd/zvault
Fix renaming bundle files
This commit is contained in:
parent
6841470981
commit
6ab28c10df
|
@ -80,24 +80,29 @@ pub fn load_bundles<P: AsRef<Path>>(path: P, bundles: &mut HashMap<BundleId, Sto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut gone = vec![];
|
let mut gone = HashSet::new();
|
||||||
for (id, bundle) in bundles.iter_mut() {
|
for (id, bundle) in bundles.iter_mut() {
|
||||||
if !bundle_paths.contains(&bundle.path) {
|
if !bundle_paths.contains(&bundle.path) {
|
||||||
gone.push(id.clone());
|
gone.insert(id.clone());
|
||||||
} else {
|
} else {
|
||||||
bundle_paths.remove(&bundle.path);
|
bundle_paths.remove(&bundle.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let gone = gone.iter().map(|id| bundles.remove(id).unwrap()).collect();
|
|
||||||
let mut new = vec![];
|
let mut new = vec![];
|
||||||
for path in bundle_paths {
|
for path in bundle_paths {
|
||||||
let bundle = StoredBundle {
|
let bundle = StoredBundle {
|
||||||
info: try!(BundleReader::load_info(&path)),
|
info: try!(BundleReader::load_info(&path)),
|
||||||
path: path
|
path: path
|
||||||
};
|
};
|
||||||
|
let id = bundle.info.id.clone();
|
||||||
|
if !bundles.contains_key(&id) {
|
||||||
new.push(bundle.clone());
|
new.push(bundle.clone());
|
||||||
bundles.insert(bundle.info.id.clone(), bundle);
|
} else {
|
||||||
|
gone.remove(&id);
|
||||||
}
|
}
|
||||||
|
bundles.insert(id, bundle);
|
||||||
|
}
|
||||||
|
let gone = gone.iter().map(|id| bundles.remove(id).unwrap()).collect();
|
||||||
Ok((new, gone))
|
Ok((new, gone))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue