feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s

Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
Alby96 authored and Alby96 committed 2026-11-15 18:11:43 +01:00
1 parent 988068ee8e
commit 20d64af4a4
793 files changed
+23882 -2096

No files matched your search

@@ -0,0 +1,51 @@
using System.Runtime.InteropServices;
namespace Chronos.Core.Windows.Services;
/// <summary>
/// Read-only look at the Service Control Manager (owner review 5, #67): whether a Windows service is installed, so the
/// desktop can warn that the 1.0 Windows Server (<see cref="LegacyServer"/>) may hold the ports its shared library wants.
/// Connect and query-status rights only, which any user has; the service is never opened for anything else.
/// </summary>
public static partial class ServiceProbe
{
/// <summary>The service name Chronos Server 1.0 installed itself under.</summary>
public const string LegacyServer = "ChronosServer";
private const uint ScManagerConnect = 0x0001;
private const uint ServiceQueryStatus = 0x0004;
private const int ErrorAccessDenied = 5;
/// <summary>True when the service <paramref name="name"/> exists on this PC; false when it does not or the manager cannot be read.</summary>
public static bool IsInstalled(string name)
{
ArgumentException.ThrowIfNullOrWhiteSpace(name);
var manager = OpenSCManagerW(null, null, ScManagerConnect);
if (manager == IntPtr.Zero) return false;
try
{
var service = OpenServiceW(manager, name, ServiceQueryStatus);
if (service != IntPtr.Zero)
{
CloseServiceHandle(service);
return true;
}
// A service the user may not even query still exists; any other error (1060, no such service) means it does not.
return Marshal.GetLastPInvokeError() == ErrorAccessDenied;
}
finally
{
CloseServiceHandle(manager);
}
}
[LibraryImport("advapi32.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial IntPtr OpenSCManagerW(string? machine, string? database, uint access);
[LibraryImport("advapi32.dll", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
private static partial IntPtr OpenServiceW(IntPtr manager, string name, uint access);
[LibraryImport("advapi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static partial bool CloseServiceHandle(IntPtr handle);
}
+1 -15
View File
@@ -7,7 +7,7 @@ namespace Chronos.Core.Windows.Shell;
/// <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"/> and refused by <see cref="CreateDirectories"/>.
/// root still under OneDrive is reported by <see cref="SyncedFolder"/>.
/// </summary>
public sealed class AppPaths
{
@@ -35,8 +35,6 @@ public sealed class AppPaths
public string CacheDirectory => Path.Combine(DataRoot, "cache");
public string ThumbnailsDirectory => Path.Combine(DataRoot, "thumbnails");
/// <summary>The OneDrive sync root containing <see cref="DataRoot"/>, or null when the location is safe.</summary>
public string? SyncedFolder { get; }
@@ -69,16 +67,4 @@ public sealed class AppPaths
: null;
return new AppPaths(location, earlier);
}
/// <summary>Creates the data, logs, cache and thumbnails folders.</summary>
/// <exception cref="InvalidOperationException">The data root lies inside a OneDrive-synced folder.</exception>
public void CreateDirectories()
{
if (SyncedFolder is not null)
throw new InvalidOperationException($"The data folder '{DataRoot}' is inside the OneDrive folder '{SyncedFolder}'; the database would be corrupted by synchronisation.");
Directory.CreateDirectory(DataRoot);
Directory.CreateDirectory(LogsDirectory);
Directory.CreateDirectory(CacheDirectory);
Directory.CreateDirectory(ThumbnailsDirectory);
}
}