Piattaforme: istanza unica dopo lo spostamento dei dati, avvio sicuro del contenitore, rilascio con prove e immagine, accesso senza reindirizzamenti esterni (pkg-1, pkg-2, pkg-3, pkg-4, pkg-5, pkg-6, websec-2, web-8, websec-3)

Registro di casa 192.168.30.23:3000 (HTTP) nel modello Unraid, in compose e nel rilascio con buildx; profilo seccomp fuori da /dati.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-14 00:59:18 +00:00
1 parent 78c92eb2a4
commit dd9320c54b
36 files changed
+1683 -152

No files matched your search

+53 -9
View File
@@ -26,9 +26,13 @@ internal sealed class DesktopApplication : Application
private readonly DesktopFolders _folders;
private readonly IDataFolderLocationStore _locations;
private readonly bool _dataFolderFixed;
private readonly SingleInstanceGuard _instance;
// The single-instance guards this Febe holds: the one of the folder it started on (taken by Program, disposed there)
// and, after a move, the one of the new folder — which every later launch finds recorded.
private readonly List<SingleInstanceGuard> _instances;
private readonly CancellationTokenSource _lifetime = new();
private string _dataFolder;
private DataFolderLock? _dataLock;
private ImageSource? _iconImage;
private TrayIcon? _tray;
private DesktopPlatform? _platform;
@@ -44,7 +48,7 @@ internal sealed class DesktopApplication : Application
_locations = locations;
_dataFolder = dataFolder;
_dataFolderFixed = dataFolderFixed;
_instance = instance;
_instances = [instance];
ShutdownMode = ShutdownMode.OnExplicitShutdown;
DispatcherUnhandledException += OnDispatcherUnhandledException;
TaskScheduler.UnobservedTaskException += (_, e) => e.SetObserved();
@@ -85,13 +89,34 @@ internal sealed class DesktopApplication : Application
{
moved = await MoveDataFolderAsync().ConfigureAwait(true);
_dataFolder = moved.DataFolder;
if (moved.TargetGuard is SingleInstanceGuard guard)
{
_instances.Add(guard);
}
if (moved.Message is { } message)
{
_tray.Notify("Cartella dei dati", message, moved.Outcome != DataFolderMoveOutcome.Moved);
}
}
var native = new WindowsShell(Dispatcher, () => _main, () => _tray);
// The folder itself is locked too: the guards are named after its path, the lock is the folder (spec §12).
if (DataFolderLock.TryAcquire(_dataFolder, out _dataLock) == DataFolderLockOutcome.HeldByAnother)
{
if (!_options.StartHidden)
{
MessageBox.Show(
$"Febe è già aperto con questa cartella dei dati ({_dataFolder}): cercalo nell'area di notifica, accanto all'orologio.",
"Febe",
MessageBoxButton.OK,
MessageBoxImage.Information);
}
await ExitAsync().ConfigureAwait(true);
return;
}
var native = new WindowsShell(Dispatcher, () => _main, () => _tray, _dataFolderFixed ? _dataFolder : null);
var shell = new DesktopShell(Dispatcher, _iconImage, native);
_platform = new DesktopPlatform(_options, shell, _locations, _dataFolderFixed);
_app = await FebeApp.StartAsync(_options.AppOptions(_dataFolder, _folders), _platform, new FebeAppHooks(), _lifetime.Token).ConfigureAwait(true);
@@ -124,13 +149,17 @@ internal sealed class DesktopApplication : Application
return;
}
_instance.Listen(request => Dispatcher.InvokeAsync(() =>
foreach (var instance in _instances)
{
if (request == InstanceRequest.Show)
instance.Listen(request => Dispatcher.InvokeAsync(() =>
{
ShowMain();
}
}));
if (request == InstanceRequest.Show)
{
ShowMain();
}
}));
}
_ = Task.Run(() => FollowEngineAsync(_lifetime.Token));
if (!_options.StartHidden || _app.Problems.Count > 0)
@@ -298,7 +327,7 @@ internal sealed class DesktopApplication : Application
bar.Value = p.FilesDone;
});
var current = _dataFolder;
return await Task.Run(() => DataFolderMove.ApplyPending(_locations, current, progress)).ConfigureAwait(true);
return await Task.Run(() => DataFolderMove.ApplyPending(_locations, current, progress, claimTarget: SingleInstanceGuard.TryAcquire)).ConfigureAwait(true);
}
finally
{
@@ -335,6 +364,21 @@ internal sealed class DesktopApplication : Application
_tray = null;
}
/// <summary>
/// Everything has stopped: the lock of the Data folder and the guard of a moved folder go last. The guard of the
/// folder Febe started on belongs to Program, which disposes it when the application returns.
/// </summary>
protected override void OnExit(ExitEventArgs e)
{
_dataLock?.Dispose();
foreach (var instance in _instances.Skip(1))
{
instance.Dispose();
}
base.OnExit(e);
}
/// <summary>Windows is shutting down or Alberto logs off: stop in order while the messages still flow (S3).</summary>
private void OnSessionEnding(object sender, SessionEndingCancelEventArgs e)
{