Drop the parameter the offline sidecar writer never used
`write_one_sidecar` took an `Option<&NextcloudBackend>` it ignored. It was a leftover from the shape the write path had before online and offline separated into two functions: the offline one records to the cache and queues, and has no server to talk to by definition. A parameter that is always `None` and always unused says the opposite — that there is a case where it is `Some` — and the next reader has to check. The closure it was threaded through is renamed to say what it does rather than how it is called. `run(None)` needed the reader to know what `None` meant; `queue_all()` is the sentence. Also regenerates the traceability matrix, which now records FR-CAT-9's queue. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -404,10 +404,12 @@ pub fn spawn_sidecar_writes(
|
||||
}
|
||||
};
|
||||
|
||||
let run = |backend: Option<&NextcloudBackend>| {
|
||||
// Every write, recorded locally and queued. The offline path, and the
|
||||
// fallback whenever a backend could not be built.
|
||||
let queue_all = || {
|
||||
let mut report = SidecarReport::default();
|
||||
for w in &writes {
|
||||
match write_one_sidecar(backend, &cache, w) {
|
||||
match write_one_sidecar(&cache, w) {
|
||||
Ok(Outcome::Uploaded) => report.written += 1,
|
||||
Ok(Outcome::Queued) => report.queued += 1,
|
||||
Err(e) => {
|
||||
@@ -421,7 +423,7 @@ pub fn spawn_sidecar_writes(
|
||||
};
|
||||
|
||||
let report = match rt {
|
||||
None => run(None),
|
||||
None => queue_all(),
|
||||
Some(rt) => rt.block_on(async {
|
||||
match NextcloudBackend::new(&creds, &user_id) {
|
||||
Ok(b) => {
|
||||
@@ -443,7 +445,7 @@ pub fn spawn_sidecar_writes(
|
||||
// will go up with the next drain.
|
||||
Err(e) => {
|
||||
log::debug!("no backend for sidecar upload ({e}); queueing");
|
||||
run(None)
|
||||
queue_all()
|
||||
}
|
||||
}
|
||||
}),
|
||||
@@ -553,11 +555,7 @@ fn amend(base: dr_pipeline::Sidecar, w: &SidecarWrite) -> dr_pipeline::Sidecar {
|
||||
/// copy when the connection returns — that reconciliation is a *merge*
|
||||
/// (FR-NC-9), not an overwrite, so building on a possibly-stale base here does
|
||||
/// not cost another device's work.
|
||||
fn write_one_sidecar(
|
||||
_backend: Option<&NextcloudBackend>,
|
||||
cache: &SidecarCache,
|
||||
w: &SidecarWrite,
|
||||
) -> Result<Outcome, String> {
|
||||
fn write_one_sidecar(cache: &SidecarCache, w: &SidecarWrite) -> Result<Outcome, String> {
|
||||
let path = sidecar_path(&w.image_path);
|
||||
let base = cache.load(&path).unwrap_or_default();
|
||||
cache.store(&path, &amend(base, w), true)?;
|
||||
|
||||
Reference in New Issue
Block a user