fix(app): a portable copy in a OneDrive folder keeps its index outside it
BRIEF §6.2 forbids a SQLite index in a synchronised folder. AppEnvironment.Detect now resolves the data folder through Core.Windows' AppPaths and OneDriveFolders: a portable copy whose .\data would lie under a OneDrive sync root (a OneDrive folder, or a Desktop or Documents folder backed up into one) keeps its data in %LOCALAPPDATA%\Titano and stays portable otherwise; AppEnvironment.SyncedFolder names the OneDrive folder so the user can be told. The pure choice lives in Core/IO/DataLocation (tested on Linux); reading the OneDrive accounts key no longer fails start-up when it cannot be read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
12 files changed
+279
-53
No files matched your search
@@ -0,0 +1,39 @@
|
||||
using Titano.Core.Windows.Shell;
|
||||
using Titano.Testing;
|
||||
|
||||
namespace Titano.Core.Windows.Tests.Shell;
|
||||
|
||||
/// <summary>The OneDrive folders of the user as Windows reports them. Serial: a test sets a process environment variable.</summary>
|
||||
[Serial]
|
||||
public sealed class OneDriveFoldersTests(TestContext context)
|
||||
{
|
||||
private const string Variable = "OneDriveCommercial";
|
||||
|
||||
[Test]
|
||||
[WindowsOnly]
|
||||
public void APortableCopyInTheUsersOneDriveKeepsItsDataInLocalAppData()
|
||||
{
|
||||
var oneDrive = context.CreateTempDirectory("onedrive");
|
||||
var previous = Environment.GetEnvironmentVariable(Variable);
|
||||
Environment.SetEnvironmentVariable(Variable, oneDrive);
|
||||
try
|
||||
{
|
||||
Assert.Contains(OneDriveFolders.SyncRoots(), root => string.Equals(root, Path.TrimEndingDirectorySeparator(oneDrive), StringComparison.OrdinalIgnoreCase));
|
||||
// A Desktop that OneDrive's folder backup moved into the sync root, with a portable copy unpacked on it.
|
||||
var app = Directory.CreateDirectory(Path.Combine(oneDrive, "Desktop", "Titano")).FullName;
|
||||
File.WriteAllText(Path.Combine(app, PortableMode.MarkerFileName), "");
|
||||
var local = context.CreateTempDirectory("local");
|
||||
|
||||
var paths = AppPaths.Resolve(app, local);
|
||||
|
||||
Assert.True(paths.IsPortable);
|
||||
Assert.Equal(Path.Combine(local, AppPaths.ProductFolderName), paths.DataRoot);
|
||||
Assert.NotNull(paths.PortableSyncRoot);
|
||||
Assert.False(paths.IsInSyncedFolder);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Environment.SetEnvironmentVariable(Variable, previous);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user