From f51c69c5e6d73f3f9482283a7dd565063bf223ce Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 12 Oct 2026 11:11:41 +0000 Subject: [PATCH] fix(settings): archive settings row and file under one lease, decimal ranges, card-only import actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The archive's index row is written under the same lease as archive.json, so two edits cannot leave them in opposite orders. - A scanner holding the restore check's scratch copy no longer turns a passed check into a failure. - Night frames and Star fields say "Enter a number" instead of "Enter a whole number". - Folder and server sources start with Keep and no eject whatever Settings › Import says for cards. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- i18n/en/Errors.resx | 1 + i18n/it/Errors.it.resx | 1 + src/Titano.App/Sections/ImportViewModel.cs | 5 ++++- src/Titano.App/Sections/SettingsViewModel.cs | 2 +- src/Titano.Data/Archiving/ArchiveService.cs | 8 ++++---- src/Titano.Data/DatabaseBackups.cs | 3 ++- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/i18n/en/Errors.resx b/i18n/en/Errors.resx index b81064b0..58e0e602 100644 --- a/i18n/en/Errors.resx +++ b/i18n/en/Errors.resx @@ -8,6 +8,7 @@ The archive could not be opened.long The current index could not be backed up or replaced; the restore runs again at the next start.long This backup cannot be restored; choose another one.long + Enter a number from {0} to {1}. Enter a whole number from {0} to {1}. Enter a folder. This is not a valid folder path. diff --git a/i18n/it/Errors.it.resx b/i18n/it/Errors.it.resx index aad76a5f..e2a3bb44 100644 --- a/i18n/it/Errors.it.resx +++ b/i18n/it/Errors.it.resx @@ -8,6 +8,7 @@ Impossibile aprire l'archivio. Non è stato possibile copiare o sostituire l'indice attuale; il ripristino riparte al prossimo avvio. Questa copia non si può ripristinare; scegline un'altra. + Inserisci un numero da {0} a {1}. Inserisci un numero intero da {0} a {1}. Inserisci una cartella. Questo non è un percorso di cartella valido. diff --git a/src/Titano.App/Sections/ImportViewModel.cs b/src/Titano.App/Sections/ImportViewModel.cs index dc33b0f3..f1965f14 100644 --- a/src/Titano.App/Sections/ImportViewModel.cs +++ b/src/Titano.App/Sections/ImportViewModel.cs @@ -713,7 +713,10 @@ public sealed class ImportViewModel : SectionViewModel var card = _selected?.Card; // A card seen for the first time takes its camera's profile once its first plan names the camera (InheritCameraAsync). _profileResolved = _selected?.Kind != SourceKind.Card || card is { ProfileJson.Length: > 0 } || card?.CameraModel is not null; - var resolved = card is null ? new ResolvedProfile(DefaultProfile(), false) : CameraProfiles.Resolve(card, camera, DefaultProfile()); + // Delete, format and eject concern cards only: a folder or server source keeps its photos whatever the defaults say. + var resolved = card is null + ? new ResolvedProfile(DefaultProfile() with { AfterImport = AfterImport.Keep, Eject = false }, false) + : CameraProfiles.Resolve(card, camera, DefaultProfile()); if (card is not null && camera is not null && resolved.FollowsCamera) await FollowCameraAsync(card, camera); else { diff --git a/src/Titano.App/Sections/SettingsViewModel.cs b/src/Titano.App/Sections/SettingsViewModel.cs index e3f87248..92972eed 100644 --- a/src/Titano.App/Sections/SettingsViewModel.cs +++ b/src/Titano.App/Sections/SettingsViewModel.cs @@ -980,7 +980,7 @@ public sealed class SettingsViewModel : SectionViewModel private static string? ValidateNumber(string text, double min, double max) => double.TryParse(text.Trim(), NumberStyles.Float, CultureInfo.CurrentCulture, out var n) && double.IsFinite(n) && n >= min && n <= max ? null - : Loc.L("Errors.Number.Range", min.ToString("0.##", Loc.Culture), max.ToString("0.##", Loc.Culture)); + : Loc.L("Errors.Number.DecimalRange", min.ToString("0.##", Loc.Culture), max.ToString("0.##", Loc.Culture)); private void Browse(EditableField field, string titleKey) { diff --git a/src/Titano.Data/Archiving/ArchiveService.cs b/src/Titano.Data/Archiving/ArchiveService.cs index 8aa03df3..562d9e42 100644 --- a/src/Titano.Data/Archiving/ArchiveService.cs +++ b/src/Titano.Data/Archiving/ArchiveService.cs @@ -177,7 +177,7 @@ public sealed class ArchiveService : IJobHandlerProvider var archive = await LoadArchiveAsync(archiveId, cancellationToken).ConfigureAwait(false); var paths = new ArchivePaths(archive.RootPath); ArchiveVolume.EnsureWritable(paths); - ArchiveManifest manifest; + // The index row is written under the same lease as the file, so two edits cannot leave them in opposite orders. using (await LeaseFile.AcquireAsync(paths.LocksDirectory, SettingsLease, _writer.Options.Owner, _writer.Options.LeaseWait, _writer.Options.LeaseDuration, cancellationToken).ConfigureAwait(false)) { @@ -186,7 +186,7 @@ public sealed class ArchiveService : IJobHandlerProvider // The name read is made usable before the edit sees it; a name the edit sets is checked as given. var settings = edit(WithUsableName(ArchiveSettings.Of(current), paths)); if (settings.Problem() is { } field) throw new ArgumentException($"The archive setting {field} is invalid.", field); - manifest = current with + var manifest = current with { Name = settings.Name.Trim(), LayoutTemplates = settings.Templates, @@ -194,9 +194,9 @@ public sealed class ArchiveService : IJobHandlerProvider ThumbnailPolicy = settings.Thumbnails, }; if (manifest != current) ManifestStore.WriteArchive(paths.ManifestPath, manifest); + Log.Info("archive", $"Settings of {paths.Root}: {manifest.LayoutTemplates.Folder} · {manifest.LayoutTemplates.File}, proxies {manifest.ProxyPolicy.LongEdge}, thumbnails {manifest.ThumbnailPolicy.LongEdge}"); + return await RegisterAsync(paths, manifest, cancellationToken).ConfigureAwait(false); } - Log.Info("archive", $"Settings of {paths.Root}: {manifest.LayoutTemplates.Folder} · {manifest.LayoutTemplates.File}, proxies {manifest.ProxyPolicy.LongEdge}, thumbnails {manifest.ThumbnailPolicy.LongEdge}"); - return await RegisterAsync(paths, manifest, cancellationToken).ConfigureAwait(false); } public static ArchiveAvailability GetAvailability(Archive archive) => ArchiveVolume.Probe(new ArchivePaths(archive.RootPath)); diff --git a/src/Titano.Data/DatabaseBackups.cs b/src/Titano.Data/DatabaseBackups.cs index 353da56e..c02710bd 100644 --- a/src/Titano.Data/DatabaseBackups.cs +++ b/src/Titano.Data/DatabaseBackups.cs @@ -132,8 +132,9 @@ public static partial class DatabaseBackups { Directory.Delete(folder, recursive: true); } - catch (IOException ex) + catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { + // A scanner can still hold the copy; the checked summary stands. Log.Warning("backup", $"The scratch copy in {folder} was not removed", ex); } }