fix(archive): polling follows the archive folder; the index follows an archive.json changed elsewhere

- The desktop's rescans run for the whole session and each one targets the archive at Settings › Archive's folder
  (as the Import and Archive screens do), so an archive created on the first run, chosen in Settings, relinked or
  imported with settings is rescanned from the next tick on, and Rescan every always reaches a live timer. The
  folder of the start is reopened (relink, interrupted renames) as soon as its archive.json is there, so an
  unplugged drive or a folder without an archive no longer stops polling for the session.
- ArchiveService.RefreshSettingsAsync reads archive.json and registers the archive again when its name, templates
  or proxy size changed elsewhere (a server's admin panel, another PC); null when the file cannot be read, is newer
  or belongs to another archive. Desktop rescans and the server's polling call it first, so imports, uploads and
  the admin panel follow the shared settings without a restart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 16:02:15 +00:00
1 parent 32a0e9bbc1
commit b344d2a527
6 files changed
+224 -31

No files matched your search

+6 -2
View File
@@ -10,9 +10,11 @@ namespace Titano.Server.Storage;
/// Polls the archive (BRIEF §7: by modification time and size, no file-system watchers): an incremental scan at start
/// and every <see cref="Interval"/> while the archive is online, so photos already in an adopted folder and sequences
/// another writer adds (a desktop sharing the archive, files copied in by hand) are indexed without an administrator's
/// rescan. A scan or rebuild of the archive that is waiting, running or paused is not queued again.
/// rescan. Settings such a writer changed in archive.json reach the index first, so uploads and the admin panel follow
/// them. A scan or rebuild of the archive that is waiting, running or paused is not queued again.
/// </summary>
public sealed class ArchivePolling(TitanoDatabase db, ServerArchive archive, JobEngineHost jobs, TimeProvider time, ILogger<ArchivePolling> logger)
public sealed class ArchivePolling(TitanoDatabase db, ServerArchive archive, ArchiveService archives, JobEngineHost jobs, TimeProvider time,
ILogger<ArchivePolling> logger)
: BackgroundService
{
/// <summary>The desktop's rhythm (it polls its archive the same way).</summary>
@@ -26,6 +28,8 @@ public sealed class ArchivePolling(TitanoDatabase db, ServerArchive archive, Job
if (!jobs.CanRun(JobKind.Scan)) return null;
var current = archive.Current;
if (ArchiveService.GetAvailability(current) != ArchiveAvailability.Online) return null;
if (await archives.RefreshSettingsAsync(current.Id, cancellationToken) is not null && await db.Archives.GetAsync(current.Id, cancellationToken) is { } row)
archive.Current = current = row;
foreach (var kind in new[] { JobKind.Scan, JobKind.Rebuild })
{
foreach (var state in Pending)