The desktop now uses the per-home layout from P3.1: each home keeps its own projects, proxies and originals, and a server is known by its id whichever address reaches it. - Settings keep the known servers (id, name, last address, certificate, aliases, originals archive). Reset and Import keep them; Export leaves them out. - SyncHost records each server the first time it signs in with an id. It names the cache and workspace folders by that id, and re-keys the folders a server had under its addresses at sign-in. The re-key waits while transfer or workspace jobs are pending. - Download originals goes to the server's own archive. It is created beside this PC's archive at the first download, and a toast says where. A sequence that already has a local copy keeps receiving into that copy's archive. A server without an id keeps the 1.0 behaviour. - At start, after the index opens and before any job runs, the folders are sorted into their homes. A toast reports the result: sorted, pending or failed. - The workspace host gives each home's store its own sync. Find, List, usage, clean-up and the trash plan and empty cover every home. Server comparisons go through the identity, so a project stays Online when its server is reached by another address. - The render-node downloads and the server import staging move into the server's folder of the cache. The cache trim keeps `servers`, and the scheduled scan also scans the originals archives. - Settings shows the Home folders rows (Workspace) and the Known servers table (Server). The diagnostics bundle lists the homes. - The dead `AppPaths.CreateDirectories` and `ThumbnailsDirectory` are removed. Refs #66 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
3.5 KiB
C#
71 lines
3.5 KiB
C#
using Chronos.Core.IO;
|
|
|
|
namespace Chronos.Core.Windows.Shell;
|
|
|
|
/// <summary>
|
|
/// Where the desktop programs keep their data (BRIEF §6.2, <see cref="DataLocation"/>): <c>%LOCALAPPDATA%\Chronos</c>, or
|
|
/// <c>.\data</c> next to the executable in portable mode. SQLite corrupts inside synchronised folders, so a portable
|
|
/// copy in a OneDrive folder keeps its data in <c>%LOCALAPPDATA%\Chronos</c> instead (<see cref="PortableSyncRoot"/>
|
|
/// names that folder to tell the user, <see cref="EarlierPortableData"/> the data it kept there before), and a data
|
|
/// root still under OneDrive is reported by <see cref="SyncedFolder"/>.
|
|
/// </summary>
|
|
public sealed class AppPaths
|
|
{
|
|
public const string ProductFolderName = DataLocation.ProductFolderName;
|
|
public const string DatabaseFileName = "chronos.db";
|
|
public const string SettingsFileName = "settings.json";
|
|
|
|
private AppPaths(DataLocation location, string? earlierPortableData)
|
|
{
|
|
DataRoot = location.Root;
|
|
IsPortable = location.IsPortable;
|
|
SyncedFolder = location.SyncedFolder;
|
|
PortableSyncRoot = location.PortableSyncRoot;
|
|
EarlierPortableData = earlierPortableData;
|
|
}
|
|
|
|
/// <summary>A portable copy, also when its data had to go to <c>%LOCALAPPDATA%\Chronos</c>.</summary>
|
|
public bool IsPortable { get; }
|
|
|
|
public string DataRoot { get; }
|
|
|
|
public string DatabasePath => Path.Combine(DataRoot, DatabaseFileName);
|
|
|
|
public string LogsDirectory => Path.Combine(DataRoot, "logs");
|
|
|
|
public string CacheDirectory => Path.Combine(DataRoot, "cache");
|
|
|
|
/// <summary>The OneDrive sync root containing <see cref="DataRoot"/>, or null when the location is safe.</summary>
|
|
public string? SyncedFolder { get; }
|
|
|
|
public bool IsInSyncedFolder => SyncedFolder is not null;
|
|
|
|
/// <summary>The OneDrive sync root a portable copy runs from, whose data is in <c>%LOCALAPPDATA%\Chronos</c> instead; null otherwise.</summary>
|
|
public string? PortableSyncRoot { get; }
|
|
|
|
/// <summary>
|
|
/// The <c>.\data</c> folder of a portable copy now in a OneDrive folder when it still holds the index or the settings
|
|
/// of an earlier start: nothing moves or deletes it, and the user is told where it is. Null otherwise.
|
|
/// </summary>
|
|
public string? EarlierPortableData { get; }
|
|
|
|
/// <summary>Paths for this process: the executable's folder decides portable mode.</summary>
|
|
public static AppPaths Resolve() => Resolve(AppContext.BaseDirectory, KnownFolders.LocalAppData);
|
|
|
|
/// <summary>Paths for an executable in <paramref name="applicationDirectory"/>, checked against the user's OneDrive roots.</summary>
|
|
public static AppPaths Resolve(string applicationDirectory, string localAppData) =>
|
|
Resolve(applicationDirectory, localAppData, OneDriveFolders.SyncRoots());
|
|
|
|
/// <summary>Paths for an executable in <paramref name="applicationDirectory"/>, checked against <paramref name="syncRoots"/>.</summary>
|
|
public static AppPaths Resolve(string applicationDirectory, string localAppData, IReadOnlyCollection<string> syncRoots)
|
|
{
|
|
var location = DataLocation.Choose(applicationDirectory, PortableMode.IsEnabled(applicationDirectory), localAppData, syncRoots);
|
|
var beside = Path.GetFullPath(Path.Combine(applicationDirectory, PortableMode.DataFolderName));
|
|
var earlier = location.PortableSyncRoot is not null
|
|
&& (File.Exists(Path.Combine(beside, DatabaseFileName)) || File.Exists(Path.Combine(beside, SettingsFileName)))
|
|
? beside
|
|
: null;
|
|
return new AppPaths(location, earlier);
|
|
}
|
|
}
|