Stop reading dates at the first sign the server is unreachable

A window of cells whose thumbnails were cached but whose dates were not
sent a header read per cell, and offline each one was three attempts at
a 15 s connect timeout: `is_transient` counts a network error as worth
retrying, and `read_metadata_only` returned a bare bool that could not
say why a read failed. So the grid sat on "reading N dates" for minutes
against a server that was not there, and no banner went up, because
nothing in that loop ever reported the connection.

`read_metadata_only` now returns a `DateRead`: reached, failed, or
offline. An offline error is returned on the first attempt rather than
retried — a dead server answers the second exactly as the first — while
a 423 lock is still retried, which is what the retry was for. The grid's
worker stops on it and sends `Offline`, as its fetch loop already did,
so the banner goes up and the bar stops. The sweep's lanes stop on it
too, one timeout each rather than one per image.
This commit is contained in:
2026-10-03 16:49:49 -04:00
parent 32a4da0e94
commit 64ea44aefe
4 changed files with 175 additions and 19 deletions
+9 -2
View File
@@ -9,7 +9,7 @@ use dr_thumbs::ThumbStore;
use std::path::PathBuf;
use std::sync::mpsc::Receiver;
use super::sweep::{flush_metadata, read_metadata_only, MetadataFound};
use super::sweep::{flush_metadata, read_metadata_only, DateRead, MetadataFound};
#[cfg(test)]
use super::sweep::{thumbnails_outstanding, SWEEP_THUMB_SIZE};
use super::thumbnails_fetch::{ThumbnailRequest, MAX_PREVIEW_BYTES};
@@ -226,7 +226,14 @@ pub fn spawn_thumbnails(
if tx.send(ThumbnailMessage::DateProgress).is_err() {
break;
}
read_metadata_only(&*backend, decoder, &req, &mut found).await;
if let DateRead::Offline(reason) =
read_metadata_only(&*backend, decoder, &req, &mut found).await
{
// Said once, as the fetch loop does, so the banner goes
// up and the bar stops rather than sweeping for ever.
let _ = tx.send(ThumbnailMessage::Offline { reason });
break;
}
if found.len() >= FLUSH_EVERY {
flush_metadata(&catalog_path, &mut found, &tx);