feat: owner review 2 phase 3: Library on the web panel, photo trash and web upload (#11)
CI / Build and test (push) Successful in 7m25s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 10s
CI / PostgreSQL 16 integration (push) Successful in 5m20s
CI / PostgreSQL 17 integration (push) Successful in 5m22s
CI / Docker image (push) Successful in 50s
Release / Build, test and publish (push) Successful in 12m1s
Release / Server image (push) Successful in 1m26s
CI / Build and test (push) Successful in 7m25s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 10s
CI / PostgreSQL 16 integration (push) Successful in 5m20s
CI / PostgreSQL 17 integration (push) Successful in 5m22s
CI / Docker image (push) Successful in 50s
Release / Build, test and publish (push) Successful in 12m1s
Release / Server image (push) Successful in 1m26s
- Web panel Library: browse, view, delete sequences and photos, mass operations (analyse, proxies, thumbnails, verify, retag, delete, CSV). It never edits the video. - Photo trash with tombstones (migration 0008): crash-safe delete and restore, hash-checked restore with reasons, and emptying only by an explicit fingerprinted job. Sync and uploads keep deleted photos deleted; an explicit "Upload again" brings one back. - Upload from the web panel: in-house SHA-256 in a worker with a fail-closed self-test, capture time from EXIF, chunked, resumable; no folders. - Desktop trash dialog with photo entries and Empty. - Admin files are revalidated (no-cache + ETag). 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 #11.
This commit is contained in:
1 parent
af9eeaab9b
commit
9aa818ed47
283 files changed
+24922
-293
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Security.Cryptography;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Chronos.Core.Archiving;
|
||||
@@ -208,6 +209,36 @@ public sealed class ArchiveModuleTests(TestContext context)
|
||||
Assert.True(Assert.NotNull(await server.Database.Sequences.GetAsync(roof.Id)).Status.HasFlag(SequenceStatus.ThumbsBuilt), "built");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AThumbnailOfAnotherPhotoAtAFramesIndexIsNotServedEvenBeforeAVerify()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context, options =>
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(options.ArchivePath, "roof"));
|
||||
File.WriteAllBytes(Path.Combine(options.ArchivePath, "roof", "IMG_0001.JPG"), Photo());
|
||||
File.WriteAllBytes(Path.Combine(options.ArchivePath, "roof", "IMG_0002.JPG"), Photo(seed: 3));
|
||||
}, ArchiveModule.Register);
|
||||
var archive = server.Services.GetRequiredService<ServerArchive>();
|
||||
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
||||
await UntilIndexedAsync(server, archive.Id, "roof");
|
||||
await UntilScannedAsync(server);
|
||||
await UntilImagesAsync(server, editor, archive.Id, "roof");
|
||||
await UntilIdleAsync(server);
|
||||
var roof = (await server.Database.Sequences.ListLocationsAsync(archive.Id)).Single(l => l.Folder == "roof");
|
||||
var frames = await server.Database.Frames.ListBySequenceAsync(roof.Id);
|
||||
Assert.True(frames.All(f => f.Sha256 is null), "adopted, not verified");
|
||||
|
||||
// The pack holds each photo's thumbnail at the other's index (a renumbering it did not follow).
|
||||
using (var pack = ThumbPackWriter.Open(new ArchivePaths(server.Options.ArchivePath).Sequence("roof").ThumbsPackPath))
|
||||
pack.Rekey(new Dictionary<int, int> { [0] = 1, [1] = 0 });
|
||||
|
||||
foreach (var frame in frames)
|
||||
{
|
||||
using var thumb = await editor.GetAsync($"/api/v1/frames/{frame.Id}/thumb");
|
||||
Assert.Equal(HttpStatusCode.NotFound, thumb.StatusCode);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SettingsADesktopChangedInArchiveJsonReachUploadsAndTheAdminPanel()
|
||||
{
|
||||
@@ -389,6 +420,59 @@ public sealed class ArchiveModuleTests(TestContext context)
|
||||
Assert.Equal(photo.Length, (await me.ReadAsync(ProtocolJson.Default.UserDto)).UsedBytes);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TheProtocolClientTakesAPhotoDeletedWhileOnItsWayAsNotSent()
|
||||
{
|
||||
// Owner review 2, R6: a repair upload whose photo the Library deletes meanwhile is refused at its completion
|
||||
// (photo_removed, nothing filed); the protocol client reports it like a photo deleted before: null, not a failure.
|
||||
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
|
||||
var (_, _, token) = await server.UserAsync("alberto", "editor");
|
||||
var admin = await server.AdminAsync();
|
||||
var path = Path.Combine(context.CreateTempDirectory("source"), "IMG_0001.JPG");
|
||||
var photo = Photo(5);
|
||||
await File.WriteAllBytesAsync(path, photo);
|
||||
using var client = new ChronosClient(server.HttpBase, new CertificatePinning([]), "Chronos Uploader (tests)") { Token = token };
|
||||
var sequence = await client.CreateSequenceAsync(new CreateSequenceRequest("Roof", null), context.Cancellation);
|
||||
// A sequence keeps one photo at least: the other is the one deleted.
|
||||
var keeper = Path.Combine(Path.GetDirectoryName(path)!, "IMG_0000.JPG");
|
||||
await File.WriteAllBytesAsync(keeper, Photo(6));
|
||||
var kept = Assert.NotNull(await client.UploadFileAsync(keeper, sequence.Id, null, ct: context.Cancellation));
|
||||
var first = Assert.NotNull(await client.UploadFileAsync(path, sequence.Id, null, ct: context.Cancellation));
|
||||
await UntilIdleAsync(server);
|
||||
File.Delete(Path.Combine(server.Options.ArchivePath, Assert.NotNull(await server.Database.Frames.GetAsync(first.FrameId)).RelativePath));
|
||||
|
||||
using var deleting = new BeforeCompletion(async () =>
|
||||
{
|
||||
await UntilIdleAsync(server);
|
||||
var current = Assert.NotNull(await server.Database.Sequences.GetAsync(sequence.Id));
|
||||
using var delete = await admin.PostAsJsonAsync($"/api/v1/sequences/{sequence.Id}/frames/delete",
|
||||
new FrameDeleteRequest([first.FrameId], current.FramesVersion, false), ProtocolJson.Default.FrameDeleteRequest);
|
||||
await delete.ExpectAsync(HttpStatusCode.OK);
|
||||
});
|
||||
using var racing = new ChronosClient(server.HttpBase, new CertificatePinning([]), "Chronos Uploader (tests)", deleting) { Token = token };
|
||||
Assert.Null(await racing.UploadFileAsync(path, sequence.Id, null, ct: context.Cancellation));
|
||||
|
||||
Assert.True(deleting.Ran, "the completion was reached");
|
||||
Assert.SequenceEqual([kept.FrameId], (await server.Database.Frames.ListBySequenceAsync(sequence.Id)).Select(f => f.Id));
|
||||
Assert.True(await server.Database.FrameRemovals.IsRemovedAsync(sequence.Id, Convert.ToHexStringLower(SHA256.HashData(photo))), "the tombstone stays");
|
||||
}
|
||||
|
||||
/// <summary>Runs a step on the server before the first upload completion goes through, then sends it on.</summary>
|
||||
private sealed class BeforeCompletion(Func<Task> step) : DelegatingHandler(new SocketsHttpHandler())
|
||||
{
|
||||
public bool Ran { get; private set; }
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (!Ran && request.Method == HttpMethod.Post && request.RequestUri?.AbsolutePath.EndsWith("/complete", StringComparison.Ordinal) == true)
|
||||
{
|
||||
Ran = true;
|
||||
await step();
|
||||
}
|
||||
return await base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnIntactCopyElsewhereDoesNotStandForTheDamagedOneOfTheTargetSequence()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user