5547: markers ask only whether a linked file is missing

missing_markers called probe, which reads and hashes a linked file whose
size or modification time differs from its stored link. With Update
Links set to Manually that difference stays, so every look of the link
watcher read the whole file again while the markers were on, for a
Modified result the markers throw away. They now use missing(), which
returns the same answer as probe for Missing (not found, or found but
unreadable) and opens a changed file without reading its content.
probe is unchanged for its other callers.

The toggle test also checks that no probe runs on the calling thread.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ruchirguitar
2026-11-27 14:58:23 +05:30
parent a6a877e693
commit 994bad5114
2 changed files with 20 additions and 1 deletions
+19 -1
View File
@@ -487,6 +487,24 @@ fn probe(g: &Group, base: LinkBase) -> (Status, Option<Found>) {
(if same { Status::Ok } else { Status::Modified }, Some(f))
}
/// Whether [`probe`] would find group `g`'s file missing, without reading or hashing its content.
/// A changed file is opened to check it can be read, and nothing more: the canvas markers ask only
/// this, and with Update Links set to Manually a changed file keeps differing from its stored link,
/// so a full probe would read the whole file again on every look while the markers are on.
fn missing(g: &Group, base: LinkBase) -> bool {
#[cfg(test)]
probe_gate::hold(&g.link.path);
let Some(f) = locate(&g.link, base) else { return true };
let l = &g.link;
if !g.plate_files.is_empty() && super::place::dcs::plate_files_changed(&g.plate_files, &f.path) {
return false;
}
if l.size == Some(f.size) && l.modified.is_some() && l.modified == f.modified {
return false;
}
fileio::read_file_head(&f.path, 0).is_err()
}
/// Is image `key` of `d` showing its preview (its file not read)?
fn previewing(d: &Document, key: &str) -> bool {
d.images.get(key).is_none_or(ImageBlob::is_proxy)
@@ -2554,7 +2572,7 @@ pub(crate) fn statuses(st: &crate::DocState) -> BTreeMap<NodeId, (Status, Option
pub(crate) fn missing_markers(doc: &Document, base: LinkBase) -> Vec<NodeId> {
groups(doc, None)
.iter()
.filter(|g| !g.ids.is_empty() && probe(g, base).0 == Status::Missing)
.filter(|g| !g.ids.is_empty() && missing(g, base))
.flat_map(|g| g.ids.iter().copied())
.filter(|id| doc.is_visible(*id))
.collect()
+1
View File
@@ -131,6 +131,7 @@ fn turning_missing_links_on_returns_before_the_file_probe_and_scans_on_the_link_
// The toggle returns while the probe of the (slow) linked file is held closed.
assert_eq!(s.execute("view.showMissingLinks", &json!({"on": true})).unwrap(), json!({"on": true}));
assert!(!gate.finished(), "the toggle waited for the file probe");
assert_eq!(gate.entered(Duration::ZERO), None, "the toggle probed the file on the calling thread");
assert!(s.doc().unwrap().missing_link_markers.is_none());
assert!(s.doc().unwrap().marked_missing_links().is_empty());
// The desktop app starts the watcher's look at once, and the probe runs there.