using Chronos.Core.Localization;
using Chronos.Data.Workspaces;
namespace Chronos.App.Workspace;
///
/// The workspace's media (phase 5c, P1): what a copy writes (proxies, and the originals besides), copying the originals of a
/// project, and going back to proxies only.
///
public sealed partial class WorkspaceHost
{
/// The bytes the first copy of a sequence's media writes into the workspace, and the free bytes of the workspace's drive.
/// The index or the archive engine is not open.
public Task CopyFactsAsync(Guid sequenceId, CancellationToken cancellationToken = default)
{
var db = _db() ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
var archives = _archives() ?? throw new WorkspaceException(Loc.L("Editor.Error.NoEngine"));
var root = Root;
return Task.Run(async () =>
{
var (bytes, free) = await WorkspaceJobs.CopyFactsAsync(db, archives, sequenceId, root, cancellationToken).ConfigureAwait(false);
return new WorkspaceCopyFacts(bytes, free);
}, cancellationToken);
}
}