feat: owner review 2 phase 4a: Reorganize sequences after import (#12)
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s
- Reorganize… on the web panel and the desktop: folder, file and title templates applied to existing sequences, with a dry run and an explicit Apply that runs as a job. - One naming rule (FrameNaming) for import, upload and Reorganize. - Crash-safe plan and file journals, held plans, stale-plan refusal; exports move with their folder. - Writers refuse a folder another program moved or gave to another sequence. - Server: POST /api/v1/archive/reorganize with a bounded plan cache; template rules. - Phase 3 docs and translations merged; strings in all 38 languages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
1 parent
9aa818ed47
commit
7e4a3b481d
416 files changed
+15304
-1572
No files matched your search
@@ -175,6 +175,22 @@ public sealed class AdminTests(TestContext context)
|
||||
|
||||
using (var bad = await admin.PutAsJsonAsync("/api/v1/archive/settings", archive with { FolderTemplate = "{year/{date" }, ProtocolJson.Default.ArchiveSettingsDto))
|
||||
Assert.Equal("folderTemplate", (await bad.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_template")).Details);
|
||||
// Templates that would hide sequences from scans, drop extensions or repeat names: refused as Reorganize refuses them,
|
||||
// with the rule after the field and the message saying why, as the desktop does.
|
||||
foreach (var (refused, details, rule) in new[]
|
||||
{
|
||||
(archive with { FolderTemplate = "Originals/{year}" }, "folderTemplate:reserved_folder", "ReservedFolder"),
|
||||
(archive with { FileTemplate = "{n}{ext}" }, "fileTemplate:extension", "Extension"),
|
||||
(archive with { FileTemplate = "{date}" }, "fileTemplate:not_unique", "NotUnique"),
|
||||
(archive with { FileTemplate = " " }, "fileTemplate", (string?)null),
|
||||
})
|
||||
{
|
||||
using var response = await admin.PutAsJsonAsync("/api/v1/archive/settings", refused, ProtocolJson.Default.ArchiveSettingsDto);
|
||||
var error = await response.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_template");
|
||||
Assert.Equal(details, error.Details);
|
||||
Assert.Equal(Chronos.Core.Localization.Loc.Get(rule is null ? "Server.Error.InvalidTemplate" : "Errors.Template." + rule,
|
||||
System.Globalization.CultureInfo.GetCultureInfo("en")), error.Message);
|
||||
}
|
||||
using (var good = await admin.PutAsJsonAsync("/api/v1/archive/settings", archive with { Name = "Studio", ProxyLongEdge = 2560 }, ProtocolJson.Default.ArchiveSettingsDto))
|
||||
{
|
||||
var saved = await good.ReadAsync(ProtocolJson.Default.ArchiveSettingsDto);
|
||||
@@ -250,4 +266,54 @@ public sealed class AdminTests(TestContext context)
|
||||
}
|
||||
await File.WriteAllBytesAsync(path, saved, context.Cancellation);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TemplatesSavedBeforeTheRulesNeverFailASaveOfTheOtherFields()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context, services: Chronos.Server.Storage.ArchiveModule.Register);
|
||||
var admin = await server.AdminAsync();
|
||||
// An archive.json of 0.1.0-rc.5 or earlier: both templates break a rule new templates are held to.
|
||||
var path = new Chronos.Core.Archiving.ArchivePaths(server.Options.ArchivePath).ManifestPath;
|
||||
var manifest = Chronos.Core.Archiving.ManifestStore.ReadArchive(path);
|
||||
Chronos.Core.Archiving.ManifestStore.WriteArchive(path, manifest with
|
||||
{
|
||||
LayoutTemplates = new Chronos.Core.Archiving.LayoutTemplates { Folder = "exports/{date}", File = "{date}" },
|
||||
});
|
||||
using var read = await admin.GetAsync("/api/v1/archive/settings");
|
||||
var archive = await read.ReadAsync(ProtocolJson.Default.ArchiveSettingsDto);
|
||||
Assert.Equal(("exports/{date}", "{date}"), (archive.FolderTemplate, archive.FileTemplate));
|
||||
|
||||
// The form sends every field with each save: the name and the proxies change, the templates stay as they are.
|
||||
using (var put = await admin.PutAsJsonAsync("/api/v1/archive/settings", archive with { Name = "Studio", ProxyLongEdge = 2560 }, ProtocolJson.Default.ArchiveSettingsDto))
|
||||
{
|
||||
var saved = await put.ReadAsync(ProtocolJson.Default.ArchiveSettingsDto);
|
||||
Assert.Equal(("Studio", "exports/{date}", "{date}", 2560), (saved.Name, saved.FolderTemplate, saved.FileTemplate, saved.ProxyLongEdge));
|
||||
}
|
||||
archive = archive with { Name = "Studio", ProxyLongEdge = 2560 };
|
||||
|
||||
// A template given anew is held to every rule; each one is fixed alone.
|
||||
using (var refused = await admin.PutAsJsonAsync("/api/v1/archive/settings", archive with { FileTemplate = "{n}{ext}" }, ProtocolJson.Default.ArchiveSettingsDto))
|
||||
Assert.Equal("fileTemplate:extension", (await refused.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_template")).Details);
|
||||
using (var folder = await admin.PutAsJsonAsync("/api/v1/archive/settings", archive with { FolderTemplate = "{year}/{date}" }, ProtocolJson.Default.ArchiveSettingsDto))
|
||||
{
|
||||
var saved = await folder.ReadAsync(ProtocolJson.Default.ArchiveSettingsDto);
|
||||
Assert.Equal(("{year}/{date}", "{date}"), (saved.FolderTemplate, saved.FileTemplate));
|
||||
}
|
||||
archive = archive with { FolderTemplate = "{year}/{date}" };
|
||||
|
||||
// A desktop fixed the file template in archive.json since the form was read: the old one the form still sends is no
|
||||
// longer the file's, so it is held to the rules and the save says which one it breaks.
|
||||
Chronos.Core.Archiving.ManifestStore.WriteArchive(path, Chronos.Core.Archiving.ManifestStore.ReadArchive(path) with
|
||||
{
|
||||
LayoutTemplates = new Chronos.Core.Archiving.LayoutTemplates { Folder = "{year}/{date}", File = "{date}_{n:0000}" },
|
||||
});
|
||||
var before = await File.ReadAllBytesAsync(path, context.Cancellation);
|
||||
using (var stale = await admin.PutAsJsonAsync("/api/v1/archive/settings", archive with { ProxyLongEdge = 1280 }, ProtocolJson.Default.ArchiveSettingsDto))
|
||||
{
|
||||
var error = await stale.ExpectErrorAsync(HttpStatusCode.BadRequest, "invalid_template");
|
||||
Assert.Equal(("fileTemplate:not_unique", Chronos.Core.Localization.Loc.Get("Errors.Template.NotUnique", System.Globalization.CultureInfo.GetCultureInfo("en"))),
|
||||
(error.Details, error.Message));
|
||||
}
|
||||
Assert.SequenceEqual(before, await File.ReadAllBytesAsync(path, context.Cancellation));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user