fix: address the phase 5 review
Video trash moves across volumes commit once the verified copy has its name and leave an undeletable source whole behind a .leftover marker that the next start settles; deletes rehash under the lease. Restores honour the names renders are writing, and encoders never overwrite an output. Routing floors at the stored settings' format, kindless stills read as stills, star trails restart per loop, and settings the encoder ignored become render warnings. The Videos section fits beside the player, plays downloaded server copies, names blocked videos and says why actions are off; the admin panel offers no download for sequences or missing files and names a filtered sequence from its record. Refs #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6d87a1bc6d
commit
1be273d0e4
38 files changed
+958
-160
No files matched your search
@@ -57,6 +57,54 @@ public sealed class VideoSourcesTests
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.Missing"), VideoText.PlayToolTip(local[1] with { Missing = true }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AServersVideoDownloadedHerePlaysFromItsCopy()
|
||||
{
|
||||
var remote = Server(Guid.CreateVersion7(), Comet, "Comet", 300, copies: ["/videos/comet.mp4"]);
|
||||
var gone = Server(Guid.CreateVersion7(), Comet, "Comet", 300);
|
||||
var local = Local(Guid.CreateVersion7(), Harbour, "Harbour sunset", 100);
|
||||
var copy = @"C:\Users\me\Videos\Chronos\comet.mp4";
|
||||
var copies = new Dictionary<Guid, IReadOnlyList<string>>
|
||||
{
|
||||
[remote.Id] = [copy],
|
||||
[gone.Id] = [@"C:\Users\me\Videos\Chronos\deleted.mp4"],
|
||||
[local.Id] = [@"C:\elsewhere\harbour.mp4"],
|
||||
};
|
||||
|
||||
var entries = VideoSources.WithLocalCopies([remote, gone, local], copies, path => path == copy);
|
||||
|
||||
var downloaded = entries[0];
|
||||
Assert.Equal(copy, downloaded.LocalPath);
|
||||
Assert.True(downloaded.HasLocalFile, "Play and Show in folder use the copy");
|
||||
Assert.SequenceEqual(["/videos/comet.mp4", copy], downloaded.Copies);
|
||||
Assert.Contains(VideoText.States(downloaded), s => s.Text == Loc.L("Videos.State.Copied"));
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.Play"), VideoText.PlayToolTip(downloaded));
|
||||
// A copy deleted since names no file to play, but is still listed; this PC's own render keeps its file.
|
||||
Assert.True(entries[1] is { LocalPath: null, HasLocalFile: false });
|
||||
Assert.Same(local, entries[2]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AServersVideoThatStaysIsNamedNotNumbered()
|
||||
{
|
||||
var known = Server(Guid.CreateVersion7(), Comet, "Comet", 300);
|
||||
var unknown = Guid.CreateVersion7();
|
||||
var server = new VideoDeletePlanDto([], 0, [new VideoBlockedDto(known.Id, VideoBlockReasons.Busy), new VideoBlockedDto(unknown, VideoBlockReasons.NotFound)], "f", DryRun: true);
|
||||
var lines = new VideoDeletePlans(null, server, new Dictionary<Guid, string> { [known.Id] = VideoDeletePlans.NameOf(known) }).Lines();
|
||||
Assert.Contains("Comet" + Loc.Separator + Formatting.LeftToRight("comet.mp4") + Loc.Separator + VideoText.BlockReason(VideoBlockReasons.Busy), lines);
|
||||
Assert.Contains(unknown.ToString("D") + Loc.Separator + VideoText.BlockReason(VideoBlockReasons.NotFound), lines, "an id the section does not show");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheDetailsLeaveOutWhatARenderDoesNotHave()
|
||||
{
|
||||
var video = Local(Guid.CreateVersion7(), Harbour, "Harbour sunset", 1_000_000);
|
||||
var still = video with { Kind = RenderKind.Still, Codec = "PngSequence", DurationSeconds = 0, Width = 6000, Height = 4000 };
|
||||
Assert.Equal(string.Join(Loc.Separator, "3840×2160", "H.264", VideoText.Duration(video), Formatting.Bytes(video.Bytes)), VideoText.Details(video));
|
||||
Assert.Equal(string.Join(Loc.Separator, "6000×4000", "PNG", Formatting.Bytes(still.Bytes)), VideoText.Details(still), "no empty duration");
|
||||
Assert.Equal(string.Join(Loc.Separator, "6000×4000", Formatting.Bytes(still.Bytes)), VideoText.Details(still with { Codec = null }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheFiltersNarrowAndTheOrdersSort()
|
||||
{
|
||||
@@ -281,9 +329,9 @@ public sealed class VideosSectionTests(TestContext context)
|
||||
public Task DeleteRunsTheDryRunFirstAndShowsItsBytesAndWhatStays() => WithSectionAsync(async (shell, section, library, dialogs) =>
|
||||
{
|
||||
await section.RefreshAsync();
|
||||
foreach (var row in section.Rows.Where(r => r.Entry.Id != library.Items[2].Render.Id)) row.IsSelected = true;
|
||||
foreach (var row in section.Rows) row.IsSelected = true;
|
||||
var selected = section.SelectedRows;
|
||||
Assert.Equal(2, selected.Count);
|
||||
Assert.Equal(3, selected.Count);
|
||||
Assert.Null(section.DeleteBlocker(selected));
|
||||
|
||||
// Kept: the plan was made, nothing was deleted.
|
||||
@@ -299,14 +347,45 @@ public sealed class VideosSectionTests(TestContext context)
|
||||
Assert.Contains(Loc.L("Videos.Delete.Blocked", Formatting.Count(1)), request.Detail!);
|
||||
Assert.Contains(VideoText.BlockReason(VideoBlockReasons.Busy), request.Detail!);
|
||||
|
||||
// Confirmed: the delete gives back the plan's fingerprint.
|
||||
// Confirmed: the delete gives back the plan's fingerprint with exactly the ids planned, the one that stays included
|
||||
// (a fingerprint of fewer ids would never match).
|
||||
dialogs.Answer = true;
|
||||
var asked = selected.Select(r => r.Entry.Id).ToList();
|
||||
await section.DeleteAsync(selected);
|
||||
Assert.SequenceEqual(["plan", "plan", "delete:fingerprint-2"], library.Calls);
|
||||
Assert.SequenceEqual(asked.Order(), library.DeletedIds.Order());
|
||||
Assert.Contains(shell.PendingToasts, t => t.Title == Loc.L("Videos.Delete.Done", Formatting.Count(2)) && !t.IsError);
|
||||
Assert.Equal(1, section.Rows.Count);
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task ADisabledActionSaysWhyInTheBarAndInTheMenu() => WithSectionAsync(async (shell, section, library, _) =>
|
||||
{
|
||||
await section.RefreshAsync();
|
||||
var video = section.Rows.Single(r => r.Entry.Id == library.Items[0].Render.Id);
|
||||
var missing = section.Rows.Single(r => r.Entry.Id == library.Items[1].Render.Id);
|
||||
// Signed out: Copy on server gives the server's reason, in the row's menu too.
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.ServerOffline"), video.MenuCopyOnServerToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.Missing"), missing.MenuShowInFolderToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.ShowInFolder"), video.MenuShowInFolderToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.Missing"), missing.MenuCopyToolTip, "the menu's Copy gives the row's reason");
|
||||
|
||||
// Two selected: Play, Show in folder and Open in Edit act on one video, and say so.
|
||||
video.IsSelected = true;
|
||||
missing.IsSelected = true;
|
||||
Assert.False(section.PlayCommand.CanExecute(null));
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.SelectOne"), section.PlayToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.SelectOne"), section.ShowInFolderToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.SelectOne"), section.OpenInEditToolTip);
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.SelectOne"), video.MenuPlayToolTip, "a selected row's menu acts on the selection");
|
||||
|
||||
// A server's video alone: not on this PC.
|
||||
var remote = new VideoRowViewModel(VideoSources.FromServer(Dto(library.Items[0]) with { Id = Guid.CreateVersion7() }));
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.ServerOnly"), VideosViewModel.OpenInEditToolTipOf([remote]));
|
||||
Assert.Equal(Loc.L("Tooltips.Videos.ServerOnly"), VideosViewModel.ShowInFolderToolTipOf([remote]));
|
||||
Assert.Equal(Loc.L("Videos.Download"), VideosViewModel.CopyTextOf([remote]));
|
||||
});
|
||||
|
||||
[Test]
|
||||
public Task ACopyWithoutAVideosFolderSaysWhy() => WithSectionAsync(async (shell, section, library, _) =>
|
||||
{
|
||||
@@ -393,6 +472,19 @@ public sealed class VideosSectionTests(TestContext context)
|
||||
var player = Assert.NotNull(section.Player);
|
||||
Assert.Equal(library.Items[0].Render.Id, player.Entry.Id);
|
||||
Layout(view);
|
||||
// Beside the player, at 1000 px too (a 1200 px window with the rail open), the list keeps its state column in view:
|
||||
// the preset, format and date columns give way.
|
||||
Layout(view, 1000);
|
||||
var pane = Descendants(view).OfType<VideoPlayerPane>().Single();
|
||||
var paneLeft = pane.TranslatePoint(new System.Windows.Point(0, 0), view).X;
|
||||
foreach (var header in new[] { "Videos.Column.State", "Videos.Column.Size" })
|
||||
{
|
||||
var cell = Descendants(view).OfType<System.Windows.Controls.TextBlock>().First(t => t.Text == Loc.L(header));
|
||||
Assert.True(cell.ActualWidth > 0, header);
|
||||
Assert.True(cell.TranslatePoint(new System.Windows.Point(cell.ActualWidth, 0), view).X <= paneLeft, $"{header} runs under the player");
|
||||
}
|
||||
Assert.Equal(System.Windows.Visibility.Collapsed,
|
||||
Descendants(view).OfType<System.Windows.Controls.TextBlock>().First(t => t.Text == Loc.L("Videos.Column.Date")).Visibility);
|
||||
section.ClosePlayerCommand.Execute(null);
|
||||
Assert.False(section.IsPlayerOpen);
|
||||
// Settings › Archive shows the videos folder row.
|
||||
@@ -413,13 +505,23 @@ public sealed class VideosSectionTests(TestContext context)
|
||||
Assert.True(shell.Settings.OpenVideosFolderCommand.CanExecute(null));
|
||||
});
|
||||
|
||||
private static void Layout(System.Windows.FrameworkElement view)
|
||||
private static void Layout(System.Windows.FrameworkElement view, double width = 1200)
|
||||
{
|
||||
view.Measure(new System.Windows.Size(1200, 800));
|
||||
view.Arrange(new System.Windows.Rect(0, 0, 1200, 800));
|
||||
view.Measure(new System.Windows.Size(width, 800));
|
||||
view.Arrange(new System.Windows.Rect(0, 0, width, 800));
|
||||
view.UpdateLayout();
|
||||
}
|
||||
|
||||
private static IEnumerable<System.Windows.DependencyObject> Descendants(System.Windows.DependencyObject root)
|
||||
{
|
||||
for (var i = 0; i < System.Windows.Media.VisualTreeHelper.GetChildrenCount(root); i++)
|
||||
{
|
||||
var child = System.Windows.Media.VisualTreeHelper.GetChild(root, i);
|
||||
yield return child;
|
||||
foreach (var below in Descendants(child)) yield return below;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The section of a shell on a fresh data folder, reading <see cref="FakeLibrary"/>, signed out, no workspace renders.</summary>
|
||||
private Task WithSectionAsync(Func<ShellViewModel, VideosViewModel, FakeLibrary, ScriptedDialogs, Task> body) => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
@@ -475,6 +577,9 @@ public sealed class VideosSectionTests(TestContext context)
|
||||
|
||||
public List<string> Calls { get; } = [];
|
||||
|
||||
/// <summary>The ids the last delete was asked for.</summary>
|
||||
public List<Guid> DeletedIds { get; private set; } = [];
|
||||
|
||||
public bool IsAvailable => true;
|
||||
|
||||
public Task<VideoPage> ListAsync(VideoQuery query, CancellationToken cancellationToken = default) => Task.FromResult(new VideoPage([.. Items], null, Items.Count));
|
||||
@@ -484,16 +589,17 @@ public sealed class VideosSectionTests(TestContext context)
|
||||
public Task<VideoDeletePlan> PlanDeleteAsync(IReadOnlyList<Guid> renderIds, CancellationToken cancellationToken = default)
|
||||
{
|
||||
lock (Calls) Calls.Add("plan");
|
||||
// Both go (the missing one only loses its row); another render, being sent, is named as staying.
|
||||
var wanted = Items.Where(i => renderIds.Contains(i.Render.Id)).ToList();
|
||||
// Both go (the missing one only loses its row); the still, being sent, is named as staying.
|
||||
var stays = new VideoBlocked(Items[2].Render.Id, VideoBlockReasons.Busy, Items[2]);
|
||||
var wanted = Items.Where(i => renderIds.Contains(i.Render.Id) && i.Render.Id != stays.RenderId).ToList();
|
||||
return Task.FromResult(new VideoDeletePlan(wanted, [stays], "fingerprint-" + Interlocked.Increment(ref _plans)));
|
||||
}
|
||||
|
||||
public Task<VideoDeleteResult> DeleteAsync(IReadOnlyList<Guid> renderIds, string fingerprint, string? deletedBy, CancellationToken cancellationToken = default)
|
||||
{
|
||||
lock (Calls) Calls.Add("delete:" + fingerprint);
|
||||
var gone = Items.Where(i => renderIds.Contains(i.Render.Id)).ToList();
|
||||
DeletedIds = [.. renderIds];
|
||||
var gone = Items.Where(i => renderIds.Contains(i.Render.Id) && i != Items[2]).ToList();
|
||||
Items.RemoveAll(gone.Contains);
|
||||
return Task.FromResult(new VideoDeleteResult(gone, [], []));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user