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>
88 lines
3.6 KiB
C#
88 lines
3.6 KiB
C#
using Chronos.Core.Windows.Shell;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Windows.Tests.Shell;
|
|
|
|
public sealed class AppPathsTests(TestContext context)
|
|
{
|
|
[Test]
|
|
public void PortableMarkerKeepsDataNextToTheExecutable()
|
|
{
|
|
var app = context.CreateTempDirectory("app");
|
|
var local = context.CreateTempDirectory("local");
|
|
File.WriteAllText(Path.Combine(app, PortableMode.MarkerFileName), "");
|
|
|
|
var paths = AppPaths.Resolve(app, local, []);
|
|
Assert.True(paths.IsPortable);
|
|
Assert.Equal(Path.Combine(app, "data"), paths.DataRoot);
|
|
Assert.Equal(Path.Combine(app, "data", "chronos.db"), paths.DatabasePath);
|
|
Assert.False(paths.IsInSyncedFolder);
|
|
Assert.Null(paths.PortableSyncRoot);
|
|
Assert.Equal(Path.Combine(app, "data", "logs"), paths.LogsDirectory);
|
|
Assert.Equal(Path.Combine(app, "data", "cache"), paths.CacheDirectory);
|
|
}
|
|
|
|
[Test]
|
|
public void InstalledModeUsesLocalAppData()
|
|
{
|
|
var app = context.CreateTempDirectory("app");
|
|
var local = context.CreateTempDirectory("local");
|
|
|
|
var paths = AppPaths.Resolve(app, local, []);
|
|
Assert.False(paths.IsPortable);
|
|
Assert.Equal(Path.Combine(local, "Chronos"), paths.DataRoot);
|
|
Assert.Equal(Path.Combine(local, "Chronos", "chronos.db"), paths.DatabasePath);
|
|
}
|
|
|
|
[Test]
|
|
public void APortableCopyInOneDriveKeepsItsDataInLocalAppData()
|
|
{
|
|
var oneDrive = context.CreateTempDirectory("onedrive");
|
|
var app = Directory.CreateDirectory(Path.Combine(oneDrive, "Tools", "Chronos")).FullName;
|
|
File.WriteAllText(Path.Combine(app, PortableMode.MarkerFileName), "");
|
|
var local = context.CreateTempDirectory("local");
|
|
|
|
var paths = AppPaths.Resolve(app, local, [oneDrive]);
|
|
Assert.True(paths.IsPortable);
|
|
Assert.Equal(Path.Combine(local, "Chronos"), paths.DataRoot);
|
|
Assert.Equal<string?>(oneDrive, paths.PortableSyncRoot);
|
|
Assert.False(paths.IsInSyncedFolder);
|
|
Assert.Equal(Path.Combine(local, "Chronos", "logs"), paths.LogsDirectory);
|
|
}
|
|
|
|
[Test]
|
|
public void DataInsideOneDriveIsReported()
|
|
{
|
|
// Local application data inside a sync root: nowhere is safe, and the app tells the user.
|
|
var oneDrive = context.CreateTempDirectory("onedrive");
|
|
var local = Directory.CreateDirectory(Path.Combine(oneDrive, "AppData", "Local")).FullName;
|
|
|
|
var paths = AppPaths.Resolve(context.CreateTempDirectory("app"), local, [oneDrive]);
|
|
Assert.True(paths.IsInSyncedFolder);
|
|
Assert.Equal<string?>(oneDrive, paths.SyncedFolder);
|
|
Assert.False(Directory.Exists(paths.DataRoot));
|
|
}
|
|
|
|
[Test]
|
|
public void SyncRootMatchingIsSegmentWise()
|
|
{
|
|
var root = Path.Combine(context.CreateTempDirectory(), "OneDrive");
|
|
Assert.Equal<string?>(root, OneDriveFolders.Containing(Path.Combine(root, "Pictures"), [root]));
|
|
Assert.Null(OneDriveFolders.Containing(root + "Backup", [root]));
|
|
}
|
|
|
|
[Test]
|
|
[WindowsOnly]
|
|
public void ResolveChecksTheRealOneDriveRoots()
|
|
{
|
|
var app = context.CreateTempDirectory("app");
|
|
File.WriteAllText(Path.Combine(app, PortableMode.MarkerFileName), "");
|
|
var paths = AppPaths.Resolve(app, KnownFolders.LocalAppData);
|
|
var roots = OneDriveFolders.SyncRoots();
|
|
Assert.True(paths.IsPortable);
|
|
Assert.Equal(OneDriveFolders.Containing(Path.Combine(app, PortableMode.DataFolderName), roots), paths.PortableSyncRoot);
|
|
Assert.Equal(OneDriveFolders.Containing(paths.DataRoot, roots), paths.SyncedFolder);
|
|
Assert.True(roots.All(Path.IsPathFullyQualified));
|
|
}
|
|
}
|