Reduce Windows desktop format, opening and edit latency

This commit is contained in:
gloamxun committed 2026-12-03 00:02:37 +08:00
1 parent 4655f8a3c9
commit 830292b9b6
15 files changed
+1006 -167

No files matched your search

@@ -71,6 +71,52 @@ impl FormatImage {
self
}
/// Bind a generated release format to the bundle that contains all its inputs.
pub fn with_bundle_location(mut self, output: &Path, bundle: &Path) -> Result<Self, String> {
let format_directory = output
.parent()
.and_then(|parent| parent.strip_prefix(bundle).ok())
.ok_or("native release format output must be inside its bundle")?;
if self
.file_dates
.iter()
.any(|date| Path::new(&date.name).is_absolute())
{
return Err("native release format observed an absolute file date".into());
}
let checked = self.build_input_checks();
let inputs = checked
.keys()
.map(PathBuf::as_path)
.chain(self.file_dates.iter().map(|date| Path::new(&date.from)))
.chain(
self.pdf_images
.iter()
.filter(|image| image.kind.reads_at_load())
.map(|image| image.path()),
)
.map(|path| {
let relative = path.strip_prefix(bundle).map_err(|_| {
format!(
"native release format input outside its bundle: {}",
path.display()
)
})?;
Ok((path.to_owned(), BTreeSet::from([relative.to_owned()])))
})
.collect::<Result<_, String>>()?;
let location = FormatLocation {
cwd: bundle.to_owned(),
format_directory: format_directory.to_owned(),
inputs,
};
if !location.is_valid() {
return Err("invalid native release format location".into());
}
self.location = Some(location);
Ok(self)
}
/// Resolve a moved tree as a group. A format copied without its relative
/// inputs still uses the original tree. Once any moved input is present,
/// every recorded input and alias in the moved tree must be available.