gui: mark media-screen imports present on this node

The Documents screen and Android's import record each imported document as
present on the importing node; the Comics, Music, PDF, Pictures and Video
screens never did, so their imports didn't count toward this node's holdings
(e.g. the Ensemble screen's per-node document counts) (audit bug 6). The mark
moves to import_job::mark_present, used by Documents and by each media
screen's file and folder imports. A comic *folder* import (lib
import_comic_tree) is not covered — it returns no ids; queued for the lib batch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Greg ShuflinandClaude Opus 5.5 committed 2026-09-28 13:36:49 -07:00
1 parent fa6fe10d8b
commit 5dbcd53167
7 files changed
+30 -8

No files matched your search

+2
View File
@@ -774,6 +774,7 @@ impl ComicsView {
None,
Some(&progress),
)
.map(|id| import_job::mark_present(&store, node, id))
} else {
import_cbz_file(
&store.blob_store,
@@ -784,6 +785,7 @@ impl ComicsView {
None,
Some(&progress),
)
.map(|id| import_job::mark_present(&store, node, id))
};
if let Err(e) = result {
errors.push(format!("Failed to import {}: {e}", path.display()));
+1 -7
View File
@@ -1593,13 +1593,7 @@ fn import_one_file(
else {
return Ok(None);
};
if let Err(e) = store
.node_doc_status_store
.batch(|tx| store.node_doc_status_store.mark_present(tx, &doc_id, &node))
{
log::error!("Failed to mark document {doc_id} present: {e}");
}
Ok(Some(doc_id))
Ok(Some(import_job::mark_present(store, node, doc_id)))
}
// ── Formatting ────────────────────────────────────────────────────────────────
+2
View File
@@ -928,6 +928,7 @@ impl MusicView {
None,
Some(&progress),
)
.map(|id| import_job::mark_present(&store, node, id))
{
errors.push(format!("Failed to import {}: {e}", path.display()));
}
@@ -982,6 +983,7 @@ impl MusicView {
None,
progress,
)
.map(|id| import_job::mark_present(&store, node, id))
.map(Some)
.map_err(|e| e.to_string())
},
+2
View File
@@ -1570,6 +1570,7 @@ impl PdfViewerView {
None,
Some(&progress),
)
.map(|id| import_job::mark_present(&store, node, id))
{
errors.push(format!("Failed to import {}: {e}", path.display()));
}
@@ -1621,6 +1622,7 @@ impl PdfViewerView {
None,
progress,
)
.map(|id| import_job::mark_present(&store, node, id))
.map(Some)
.map_err(|e| e.to_string())
},
+2
View File
@@ -540,6 +540,7 @@ impl PicturesView {
None,
Some(&progress),
)
.map(|id| import_job::mark_present(&store, node, id))
{
errors.push(format!("Failed to import {}: {e}", path.display()));
}
@@ -591,6 +592,7 @@ impl PicturesView {
None,
progress,
)
.map(|id| import_job::mark_present(&store, node, id))
.map(Some)
.map_err(|e| e.to_string())
},
+4 -1
View File
@@ -237,7 +237,9 @@ impl VideoView {
node,
None,
Some(&progress),
) {
)
.map(|id| import_job::mark_present(&store, node, id))
{
errors.push(format!("Failed to import {}: {e}", path.display()));
}
progress.tick_path(path);
@@ -290,6 +292,7 @@ impl VideoView {
None,
progress,
)
.map(|id| import_job::mark_present(&store, node, id))
.map(Some)
.map_err(|e| e.to_string())
},
+17
View File
@@ -12,9 +12,12 @@ use std::sync::Arc;
use gpui::SharedString;
use synchronicity::copy::busy;
use synchronicity::documents::DocumentID;
use synchronicity::documents::import::{ImportProgress, ImportTotals};
use synchronicity::jobs::runner::{JobHandle, JobRunner};
use synchronicity::jobs::{JobKind, JobOrigin, JobSubject};
use synchronicity::node::NodePubkey;
use synchronicity::stores::Store;
/// What a screen's error banner says when [`start`] is refused, so a click that
/// does nothing still says why.
@@ -77,3 +80,17 @@ pub fn files_label(paths: &[PathBuf]) -> String {
_ => format!("{} files", paths.len()),
}
}
/// Record that `doc_id`, just imported, is present on this node, so an import
/// from any screen counts toward this node's holdings the way the Documents
/// screen's and Android's always have. Best-effort: a failure is logged and the
/// import stands. Returns `doc_id` so it slots into a `.map`.
pub fn mark_present(store: &Store, node: NodePubkey, doc_id: DocumentID) -> DocumentID {
if let Err(e) = store
.node_doc_status_store
.batch(|tx| store.node_doc_status_store.mark_present(tx, &doc_id, &node))
{
log::error!("Failed to mark document {doc_id} present: {e}");
}
doc_id
}