feat: work board, no usage data, archive folder tree, deploy guide (owner review 4 + owner review 1 phase 6) (#62)
CI / Build and test (push) Successful in 10m37s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 16m19s
CI / PostgreSQL 16 integration (push) Successful in 10m19s
CI / PostgreSQL 17 integration (push) Successful in 11m27s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m34s
CI / Build and test (push) Successful in 10m37s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 16m19s
CI / PostgreSQL 16 integration (push) Successful in 10m19s
CI / PostgreSQL 17 integration (push) Successful in 11m27s
CI / Docker image (push) Successful in 57s
Release / Server image (push) Successful in 1m34s
Owner review 4 and owner review 1 phase 6. - Work board in Videos (desktop and admin panel): Published and Workspace lanes (#29). - Anonymous usage counts removed: Chronos sends nothing about its use (#30). - The archive's whole folder tree is created inside any archive root, on the server and the desktop (#31). - Video cards start with the preset; sizes keep number and unit together (#28). - Deploy guide docs/deploy (Docker, Unraid, desktop), BRIEF §24, original documentation in docs/reference/original (#22). Closes #22 #28 #29 #30 #31 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 #62.
This commit is contained in:
1 parent
728ffa35cb
commit
0075065884
304 files changed
+6892
-325
No files matched your search
@@ -19,6 +19,15 @@ public static class ArchiveLayout
|
||||
/// <summary>Resumable plans of mass operations (rename).</summary>
|
||||
public const string JournalFolder = "journal";
|
||||
|
||||
/// <summary>Deleted sequences, photos and renders inside the root <see cref="MetaFolder"/>, kept until Empty.</summary>
|
||||
public const string TrashFolder = "trash";
|
||||
|
||||
/// <summary>The photo entries inside <see cref="TrashFolder"/>.</summary>
|
||||
public const string TrashPhotosFolder = "photos";
|
||||
|
||||
/// <summary>The deleted renders inside <see cref="TrashFolder"/> (owner review 1, R9).</summary>
|
||||
public const string TrashVideosFolder = "videos";
|
||||
|
||||
public const string OriginalsFolder = "originals";
|
||||
public const string ProxiesFolder = "proxies";
|
||||
public const string ExportsFolder = "exports";
|
||||
@@ -86,6 +95,9 @@ public sealed class ArchivePaths
|
||||
public string LocksDirectory => Path.Combine(MetaDirectory, ArchiveLayout.LocksFolder);
|
||||
public string StagingDirectory => Path.Combine(MetaDirectory, ArchiveLayout.StagingFolder);
|
||||
public string JournalDirectory => Path.Combine(MetaDirectory, ArchiveLayout.JournalFolder);
|
||||
public string TrashDirectory => Path.Combine(MetaDirectory, ArchiveLayout.TrashFolder);
|
||||
public string TrashPhotosDirectory => Path.Combine(TrashDirectory, ArchiveLayout.TrashPhotosFolder);
|
||||
public string TrashVideosDirectory => Path.Combine(TrashDirectory, ArchiveLayout.TrashVideosFolder);
|
||||
|
||||
/// <summary>Paths of the sequence stored in <paramref name="relativeFolder"/> (forward slashes).</summary>
|
||||
public SequencePaths Sequence(string relativeFolder) => new(this, relativeFolder);
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
using Chronos.Core.Localization;
|
||||
|
||||
namespace Chronos.Core.Archiving;
|
||||
|
||||
/// <summary>Why the folders of an archive's layout could not all be created (<see cref="ArchiveStructure.Ensure"/>).</summary>
|
||||
public enum ArchiveStructureProblem
|
||||
{
|
||||
None,
|
||||
|
||||
/// <summary>The drive or share of the archive is not there (unplugged, disconnected, not ready).</summary>
|
||||
Unavailable,
|
||||
|
||||
/// <summary>The account Chronos runs as may not create folders there.</summary>
|
||||
Denied,
|
||||
|
||||
/// <summary>The drive or share is read-only (write-protected disk, read-only mount).</summary>
|
||||
ReadOnly,
|
||||
|
||||
/// <summary>Any other failure, a file where a folder belongs included.</summary>
|
||||
Failed,
|
||||
}
|
||||
|
||||
/// <summary>What <see cref="ArchiveStructure.Ensure"/> found and did.</summary>
|
||||
/// <param name="Root">The archive root.</param>
|
||||
/// <param name="Created">The folders created, parents first.</param>
|
||||
/// <param name="Problem">Why the layout is not complete; <see cref="ArchiveStructureProblem.None"/> when it is.</param>
|
||||
/// <param name="Folder">The folder that could not be created; null when the layout is complete.</param>
|
||||
/// <param name="Detail">The system's own text of the failure, for the log; null when the layout is complete.</param>
|
||||
public sealed record ArchiveStructureReport(string Root, IReadOnlyList<string> Created, ArchiveStructureProblem Problem, string? Folder, string? Detail)
|
||||
{
|
||||
public bool IsComplete => Problem == ArchiveStructureProblem.None;
|
||||
|
||||
/// <summary>The problem as one localized sentence naming the folder; null when the layout is complete.</summary>
|
||||
public string? Message => Problem switch
|
||||
{
|
||||
ArchiveStructureProblem.None => null,
|
||||
ArchiveStructureProblem.Unavailable => Loc.L("Archive.Structure.Unavailable", Folder ?? Root),
|
||||
ArchiveStructureProblem.Denied => Loc.L("Archive.Structure.Denied", Folder ?? Root),
|
||||
ArchiveStructureProblem.ReadOnly => Loc.L("Archive.Structure.ReadOnly", Folder ?? Root),
|
||||
_ => Loc.L("Archive.Structure.Failed", Folder ?? Root),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The folders of an archive's layout could not all be created; the message is one localized sentence.</summary>
|
||||
public sealed class ArchiveStructureException(ArchiveStructureReport report) : IOException(report.Message)
|
||||
{
|
||||
public ArchiveStructureReport Report { get; } = report;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The folders every archive holds (BRIEF §7) whatever made it: the root's <c>.chronos</c> with <c>locks</c>,
|
||||
/// <c>journal</c>, <c>staging</c> and <c>trash</c>, whose <c>photos</c> and <c>videos</c> areas hold the deleted photos and
|
||||
/// renders. <c>archive.json</c> is the archive service's (it needs a name and an id); the folders of a sequence
|
||||
/// (<c>originals</c>, <c>proxies</c>, <c>exports</c>, its <c>.chronos</c>) are made when the sequence is, and the
|
||||
/// trash's <c>.erasing</c> and <c>.erased</c> only when Empty needs them.
|
||||
/// </summary>
|
||||
public static class ArchiveStructure
|
||||
{
|
||||
private const int WriteProtected = unchecked((int)0x80070013); // ERROR_WRITE_PROTECT
|
||||
private const int NotReady = unchecked((int)0x80070015); // ERROR_NOT_READY
|
||||
private const int BadNetworkPath = unchecked((int)0x80070035); // ERROR_BAD_NETPATH
|
||||
private const int NetworkNameDeleted = unchecked((int)0x80070040); // ERROR_NETNAME_DELETED
|
||||
private const int BadNetworkName = unchecked((int)0x80070043); // ERROR_BAD_NET_NAME
|
||||
private const int UnixReadOnlyFileSystem = 30; // EROFS, which .NET keeps as the IOException's HResult
|
||||
private const int UnixNoDevice = 19; // ENODEV
|
||||
|
||||
/// <summary>The layout's folders of <paramref name="archive"/>, parents first, the root included.</summary>
|
||||
public static IReadOnlyList<string> Folders(ArchivePaths archive)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(archive);
|
||||
return [archive.Root, archive.MetaDirectory, archive.LocksDirectory, archive.JournalDirectory, archive.StagingDirectory,
|
||||
archive.TrashDirectory, archive.TrashPhotosDirectory, archive.TrashVideosDirectory];
|
||||
}
|
||||
|
||||
/// <summary>The layout's folders that are not there, parents first; nothing is created.</summary>
|
||||
public static IReadOnlyList<string> Missing(ArchivePaths archive) => [.. Folders(archive).Where(f => !Directory.Exists(f))];
|
||||
|
||||
/// <summary>
|
||||
/// Creates the layout's folders that are missing, never touching what is there: an existing folder and every file
|
||||
/// stay as they are, and a file where a folder belongs is reported, not replaced. Safe to run any number of times
|
||||
/// and by several processes at once. Stops at the first folder that cannot be created and says why; never throws for
|
||||
/// the file system.
|
||||
/// </summary>
|
||||
/// <param name="archive">The archive root.</param>
|
||||
/// <param name="createRoot">Whether a missing root is created (a new archive); otherwise it is reported unavailable.</param>
|
||||
/// <param name="createDirectory">Creates one folder (<see cref="Directory.CreateDirectory(string)"/>; tests replace it).</param>
|
||||
public static ArchiveStructureReport Ensure(ArchivePaths archive, bool createRoot = false, Action<string>? createDirectory = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(archive);
|
||||
createDirectory ??= static path => Directory.CreateDirectory(path);
|
||||
var created = new List<string>();
|
||||
if (!Directory.Exists(archive.Root) && (!createRoot || !VolumeIsThere(archive.Root)))
|
||||
return new(archive.Root, created, ArchiveStructureProblem.Unavailable, archive.Root, null);
|
||||
foreach (var folder in Folders(archive))
|
||||
{
|
||||
if (Directory.Exists(folder)) continue;
|
||||
try
|
||||
{
|
||||
createDirectory(folder);
|
||||
created.Add(folder);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
return new(archive.Root, created, Classify(ex), folder, ex.Message);
|
||||
}
|
||||
}
|
||||
return new(archive.Root, created, ArchiveStructureProblem.None, null, null);
|
||||
}
|
||||
|
||||
/// <summary>Why creating a folder failed, from the exception the file system threw.</summary>
|
||||
public static ArchiveStructureProblem Classify(Exception ex) => ex switch
|
||||
{
|
||||
UnauthorizedAccessException => ArchiveStructureProblem.Denied,
|
||||
DirectoryNotFoundException or DriveNotFoundException => ArchiveStructureProblem.Unavailable,
|
||||
IOException { HResult: WriteProtected } => ArchiveStructureProblem.ReadOnly,
|
||||
IOException { HResult: NotReady or BadNetworkPath or NetworkNameDeleted or BadNetworkName } => ArchiveStructureProblem.Unavailable,
|
||||
IOException { HResult: UnixReadOnlyFileSystem } when !OperatingSystem.IsWindows() => ArchiveStructureProblem.ReadOnly,
|
||||
IOException { HResult: UnixNoDevice } when !OperatingSystem.IsWindows() => ArchiveStructureProblem.Unavailable,
|
||||
_ => ArchiveStructureProblem.Failed,
|
||||
};
|
||||
|
||||
/// <summary>Whether the drive or share <paramref name="root"/> lives on is there.</summary>
|
||||
private static bool VolumeIsThere(string root)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Path.GetPathRoot(root) is { Length: > 0 } volume && Directory.Exists(volume);
|
||||
}
|
||||
catch (Exception ex) when (ex is ArgumentException or IOException or UnauthorizedAccessException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user