Compare commits

...
Author SHA1 Message Date
poli0981 7af21aab09 Merge remote-tracking branch 'origin/main' into chore/dev-data-root 2026-11-03 11:05:13 +07:00
poli0981 e5f2835229 Merge pull request #43 from poli0981/feat/catalog-c2
feat(catalog): Spotify's third-party sign-in hops, and audioPin for calls
2026-11-03 10:53:27 +07:00
poli0981andClaude Opus 5.5 76b27e86ed chore: a development build can use a data root of its own
A Debug build reads OMNIDECK_DATA_ROOT and, when it is set, keeps its
settings, database, web sign-ins and logs there, under a single-instance
name of its own, so it runs beside an installed OmniDeck without touching
that copy's data. Release builds never read the variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 10:52:59 +07:00
5 changed files with 104 additions and 4 deletions

No files matched your search

+7
View File
@@ -19,6 +19,13 @@ dotnet test OmniDeck.slnx
dotnet run --project src/OmniDeck.App
```
To run a development build beside an installed OmniDeck, give it a data root of its own. Only Debug builds read the variable, so the installed copy keeps its settings, sign-ins and database, and the two run side by side:
```powershell
$env:OMNIDECK_DATA_ROOT = "$env:TEMP\OmniDeck.Dev"
dotnet run --project src/OmniDeck.App
```
## Code style & quality gates (enforced in CI)
- `.editorconfig` is authoritative. `dotnet format OmniDeck.slnx --verify-no-changes` must pass.
+8 -2
View File
@@ -35,11 +35,13 @@ namespace OmniDeck.App;
public partial class OdApp
{
private readonly OdSingleInstanceGuard _guard;
private readonly OdDataRoot _dataRoot;
private ServiceProvider? _services;
internal OdApp(OdSingleInstanceGuard guard)
internal OdApp(OdSingleInstanceGuard guard, OdDataRoot dataRoot)
{
_guard = guard;
_dataRoot = dataRoot;
}
/// <summary>The legal documents that ship next to the executable.</summary>
@@ -76,10 +78,14 @@ public partial class OdApp
private void Start(string[] args)
{
var startMinimized = args.Contains(OdRunKeyStartup.MinimizedArgument, StringComparer.OrdinalIgnoreCase);
var dataRoot = OdDataRoot.Default;
var dataRoot = _dataRoot;
dataRoot.EnsureCreated();
Log.Logger = OdLogging.CreateLogger(dataRoot);
Log.ForContext<OdApp>().Information("OmniDeck {Version} starting", OdVersionInfo.FromAssembly(typeof(OdApp).Assembly).DisplayText);
if (!dataRoot.IsDefault)
{
Log.ForContext<OdApp>().Warning("Development data root in use: {DataRoot}", dataRoot.Root);
}
// The catalog decides which web-app modules exist, so it loads before the container is built.
var catalog = OdCatalogService.LoadInstalled(dataRoot, TimeProvider.System, Log.Logger);
+17 -2
View File
@@ -19,15 +19,30 @@ internal static class Program
.OnBeforeUninstallFastCallback(_ => OdDataRoot.Default.TryDelete())
.Run();
using var guard = new OdSingleInstanceGuard();
var dataRoot = DataRoot();
using var guard = new OdSingleInstanceGuard(dataRoot.InstanceSuffix);
if (!guard.IsPrimaryInstance)
{
guard.SignalPrimaryInstance();
return 0;
}
var app = new OdApp(guard);
var app = new OdApp(guard, dataRoot);
app.InitializeComponent();
return app.Run();
}
/// <summary>
/// The signed-in user's data root. A Debug build can be pointed elsewhere with
/// <see cref="OdDataRoot.OverrideVariable"/>, so it runs beside an installed OmniDeck without
/// touching its data; a Release build never reads the variable.
/// </summary>
private static OdDataRoot DataRoot()
{
#if DEBUG
return OdDataRoot.Choose(Environment.GetEnvironmentVariable(OdDataRoot.OverrideVariable));
#else
return OdDataRoot.Default;
#endif
}
}
+27
View File
@@ -1,3 +1,6 @@
using System.Security.Cryptography;
using System.Text;
namespace OmniDeck.Core.Storage;
/// <summary>
@@ -11,6 +14,13 @@ public sealed class OdDataRoot
/// <summary>The data root's folder name under <c>%LocalAppData%</c>.</summary>
public const string FolderName = "OmniDeck.Data";
/// <summary>
/// The environment variable a Debug build reads to use a data root of its own, so a development
/// copy runs beside an installed OmniDeck without touching its data (CONTRIBUTING.md). Release
/// builds never read it.
/// </summary>
public const string OverrideVariable = "OMNIDECK_DATA_ROOT";
/// <summary>Velopack's install folder name, which the data root must never be.</summary>
private const string InstallFolderName = "OmniDeck";
@@ -28,8 +38,25 @@ public sealed class OdDataRoot
public static OdDataRoot Default { get; } = new(Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), FolderName));
/// <summary><paramref name="overridePath"/> when it is set, otherwise <see cref="Default"/>.</summary>
public static OdDataRoot Choose(string? overridePath) =>
string.IsNullOrWhiteSpace(overridePath) ? Default : new OdDataRoot(overridePath);
public string Root { get; }
/// <summary>Whether this is the signed-in user's real data root.</summary>
public bool IsDefault => string.Equals(
Path.TrimEndingDirectorySeparator(Root), Path.TrimEndingDirectorySeparator(Default.Root), StringComparison.OrdinalIgnoreCase);
/// <summary>
/// Tells single-instance guards apart per data root: <see langword="null"/> for the real one and a
/// short hash of the path otherwise, so a development build with a root of its own does not hand
/// off to the installed OmniDeck.
/// </summary>
public string? InstanceSuffix => IsDefault
? null
: "." + Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(Path.TrimEndingDirectorySeparator(Root).ToUpperInvariant())), 0, 4);
public string SettingsFile => Path.Combine(Root, "settings.json");
public string DatabaseFile => Path.Combine(Root, "omnideck.db");
@@ -34,6 +34,51 @@ public sealed class OdDataRootTests
Assert.Throws<ArgumentException>(() => new OdDataRoot(temp.Combine(name)));
}
[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData(" ")]
public void Choose_WithoutAnOverride_IsTheRealRoot(string? overridePath)
{
var root = OdDataRoot.Choose(overridePath);
Assert.Same(OdDataRoot.Default, root);
Assert.True(root.IsDefault);
Assert.Null(root.InstanceSuffix);
}
[Fact]
public void Choose_WithAnOverride_UsesIt_AndGetsAnInstanceOfItsOwn()
{
using var temp = new OdTempDirectory();
var path = temp.Combine("OmniDeck.Dev");
var root = OdDataRoot.Choose(path);
Assert.Equal(path, root.Root, StringComparer.OrdinalIgnoreCase);
Assert.False(root.IsDefault);
Assert.Matches("^\\.[0-9A-F]{8}$", root.InstanceSuffix);
Assert.Equal(root.InstanceSuffix, OdDataRoot.Choose(path.ToUpperInvariant() + Path.DirectorySeparatorChar).InstanceSuffix, StringComparer.Ordinal);
Assert.NotEqual(root.InstanceSuffix, OdDataRoot.Choose(temp.Combine("OmniDeck.Other")).InstanceSuffix, StringComparer.Ordinal);
}
[Fact]
public void Choose_StillRejectsVelopacksInstallFolder()
{
using var temp = new OdTempDirectory();
Assert.Throws<ArgumentException>(() => OdDataRoot.Choose(temp.Combine("OmniDeck")));
}
[Fact]
public void Choose_TheRealPathItself_CountsAsTheRealRoot()
{
var root = OdDataRoot.Choose(OdDataRoot.Default.Root + Path.DirectorySeparatorChar);
Assert.True(root.IsDefault);
Assert.Null(root.InstanceSuffix);
}
[Fact]
public void EnsureCreated_ThenTryDelete_LeavesNothing()
{