Merge branch 'fix/setup-bundle': .titano project files, per-machine server, services and Run entries handled by setup, per-product data removal
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
49 files changed
+2741
-128
No files matched your search
@@ -0,0 +1,42 @@
|
||||
using Titano.Core.Model;
|
||||
using Titano.Core.Project;
|
||||
|
||||
namespace Titano.Data.Processing;
|
||||
|
||||
/// <summary>
|
||||
/// <c>.titano</c> project files (BRIEF §18) against this index: the file for a sequence of one of its archives, and
|
||||
/// the sequence a file names.
|
||||
/// </summary>
|
||||
public static class ProjectBundles
|
||||
{
|
||||
/// <summary>
|
||||
/// The project file of <paramref name="sequenceId"/> with <paramref name="project"/> (the editor's current
|
||||
/// settings), whose frame positions refer to <paramref name="frames"/> frames.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">The sequence is not in the index.</exception>
|
||||
public static async Task<ProjectBundle> CreateAsync(TitanoDatabase db, Guid sequenceId, ProjectSettings project, int frames,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var sequence = await db.Sequences.GetAsync(sequenceId, cancellationToken).ConfigureAwait(false)
|
||||
?? throw new InvalidOperationException($"Sequence {sequenceId} is not in the index.");
|
||||
var archive = await db.Archives.GetAsync(sequence.ArchiveId, cancellationToken).ConfigureAwait(false);
|
||||
return new ProjectBundle(
|
||||
new BundleArchive(sequence.ArchiveId, archive?.Name ?? string.Empty, archive?.RootPath),
|
||||
new BundleSequence(sequence.Id, sequence.Folder, sequence.DisplayTitle, frames),
|
||||
project,
|
||||
DateTimeOffset.UtcNow);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sequence <paramref name="bundle"/> names: by its id, else the sequence in the same folder of the same
|
||||
/// archive (an index rebuilt elsewhere, or a folder adopted again, gives it a new id). Null when this index has
|
||||
/// neither: the archive is not added here, or the sequence was deleted.
|
||||
/// </summary>
|
||||
public static async Task<Sequence?> ResolveAsync(TitanoDatabase db, ProjectBundle bundle, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (await db.Sequences.GetAsync(bundle.Sequence.Id, cancellationToken).ConfigureAwait(false) is { } byId) return byId;
|
||||
var locations = await db.Sequences.ListLocationsAsync(bundle.Archive.Id, cancellationToken).ConfigureAwait(false);
|
||||
var match = locations.FirstOrDefault(l => string.Equals(l.Folder, bundle.Sequence.Folder, StringComparison.OrdinalIgnoreCase));
|
||||
return match is null ? null : await db.Sequences.GetAsync(match.Id, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user