Capture editor file dates and make desktop ZIP import observable
This commit is contained in:
1 parent
0ea71d57a9
commit
fbc339f5c4
11 files changed
+231
-72
No files matched your search
@@ -158,6 +158,15 @@ impl ProjectSnapshot {
|
||||
pub fn with_external_resources(
|
||||
self: &Arc<Self>,
|
||||
resources: &BTreeMap<PathBuf, Arc<[u8]>>,
|
||||
) -> Result<Arc<Self>, String> {
|
||||
self.with_external_resources_and_dates(resources, &BTreeMap::new())
|
||||
}
|
||||
|
||||
/// Attach dates captured with newly observed external resource bytes.
|
||||
pub fn with_external_resources_and_dates(
|
||||
self: &Arc<Self>,
|
||||
resources: &BTreeMap<PathBuf, Arc<[u8]>>,
|
||||
dates: &BTreeMap<PathBuf, FileModificationTime>,
|
||||
) -> Result<Arc<Self>, String> {
|
||||
if resources.keys().all(|path| self.files.contains_key(path)) {
|
||||
return Ok(self.clone());
|
||||
@@ -175,6 +184,9 @@ impl ProjectSnapshot {
|
||||
}
|
||||
next.files
|
||||
.insert(path.clone(), Self::capture(path.clone(), data.clone()));
|
||||
if let Some(&date) = dates.get(path) {
|
||||
next.file_modifications.insert(path.clone(), date);
|
||||
}
|
||||
next.directories
|
||||
.extend(path.ancestors().skip(1).map(Path::to_path_buf));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user