fix(settings): archive settings row and file under one lease, decimal ranges, card-only import actions
- 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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
6 files changed
+13
-7
No files matched your search
@@ -8,6 +8,7 @@
|
||||
<data name="Errors.Archive.Open" xml:space="preserve"><value>The archive could not be opened.</value><comment>long</comment></data>
|
||||
<data name="Errors.Backup.Deferred" xml:space="preserve"><value>The current index could not be backed up or replaced; the restore runs again at the next start.</value><comment>long</comment></data>
|
||||
<data name="Errors.Backup.Unreadable" xml:space="preserve"><value>This backup cannot be restored; choose another one.</value><comment>long</comment></data>
|
||||
<data name="Errors.Number.DecimalRange" xml:space="preserve"><value>Enter a number from {0} to {1}.</value></data>
|
||||
<data name="Errors.Number.Range" xml:space="preserve"><value>Enter a whole number from {0} to {1}.</value></data>
|
||||
<data name="Errors.Path.Empty" xml:space="preserve"><value>Enter a folder.</value></data>
|
||||
<data name="Errors.Path.Invalid" xml:space="preserve"><value>This is not a valid folder path.</value></data>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<data name="Errors.Archive.Open" xml:space="preserve"><value>Impossibile aprire l'archivio.</value></data>
|
||||
<data name="Errors.Backup.Deferred" xml:space="preserve"><value>Non è stato possibile copiare o sostituire l'indice attuale; il ripristino riparte al prossimo avvio.</value></data>
|
||||
<data name="Errors.Backup.Unreadable" xml:space="preserve"><value>Questa copia non si può ripristinare; scegline un'altra.</value></data>
|
||||
<data name="Errors.Number.DecimalRange" xml:space="preserve"><value>Inserisci un numero da {0} a {1}.</value></data>
|
||||
<data name="Errors.Number.Range" xml:space="preserve"><value>Inserisci un numero intero da {0} a {1}.</value></data>
|
||||
<data name="Errors.Path.Empty" xml:space="preserve"><value>Inserisci una cartella.</value></data>
|
||||
<data name="Errors.Path.Invalid" xml:space="preserve"><value>Questo non è un percorso di cartella valido.</value></data>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user