Integrazione 0.1.1: unione di correzione/prove-su-windows

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

# Conflicts:
#	docs/decisioni.md
This commit is contained in:
Alby96 committed 2026-10-20 18:05:33 +02:00
commit 5dc9b4c6ae
7 files changed
+105 -16

No files matched your search

+4
View File
@@ -255,3 +255,7 @@ Ogni scelta tecnica presa strada facendo, con data e motivo (specifica §15).
| 2026-10-20 | Un solo WebView alla volta in `WebView2Host`: l'avvio, dentro la sezione esclusiva, non fa nulla se un WebView è già collegato, chiude prima i resti di uno morto, e se fallisce chiude da sé ciò che ha creato (il ciclo dei tentativi non chiude più niente da fuori); la ripartenza dopo un arresto del processo usa lo stesso avvio; chiudere un WebView ne cambia la generazione, così i suoi eventi tardivi non contano | Revisione del ramo: un «Scollega» durante i tentativi del primo avvio faceva partire il browser, poi il tentativo in attesa ne apriva un secondo nella stessa finestra senza chiudere il primo. Il processo orfano teneva il profilo: il «Scollega» dopo aspettava 20 s e non cancellava la sessione di Instagram, l'uscita aspettava 15 s a vuoto |
| 2026-10-20 | All'uscita il primo avvio e il ciclo di ripartenza di `WebView2Browser` smettono subito di aspettare WebView2: `WebView2Host.StartAsync` onora il suo token (un avvio non ancora cominciato non comincia, uno in corso finisce da sé e l'arresto chiude ciò che lascia, anche se arriva dopo i 30 s); `WebView2Browser.DisposeAsync` aspetta il ciclo al più 30 s. «Scollega», una volta cominciato, va fino in fondo e resta coperto dai 30 s dell'arresto | Revisione del ramo: il limite di 30 s copriva solo un «Scollega» in corso. `FebeApp` aspetta `RunAsync` prima di chiudere il browser, e `RunAsync` e il ciclo aspettavano WebView2 senza limite; interrompere «Scollega» a metà lascerebbe invece fermo il motore |
| 2026-10-20 | Collegamento, pannello «collegato» senza nome dell'account (subito dopo «Ho finito», prima del primo giro): titolo «Collegato» e sotto «Nome non ancora noto», come il riquadro di stato | Provando a mano su Windows la pagina diceva «Collegato come @»; il mockup 10 mostra solo il caso con il nome |
| 2026-10-20 | Prove portabili fra Linux e Windows: i percorsi attesi si calcolano come li calcola il sistema (`Path.GetFullPath` per il profilo del browser e per `/importa`, `LibraryLayout.ToStored` per il percorso mostrato in Docker) invece di essere scritti alla Linux | Febe per Windows gira su Windows e le prove devono passare dove gira il prodotto; su Linux il testo atteso è identico a prima, quindi lì non cambia nulla |
| 2026-10-20 | Prova della cartella dei dati su una condivisione: su Linux il montaggio cifs iniettato come prima, su Windows un percorso UNC verso `febe-prova.invalid`, riconosciuto dalla sola forma; il controllo «niente scritto nella cartella dei dati» resta solo su Linux | Stesso comportamento sui due sistemi, ognuno con il suo modo di riconoscere la rete (su Windows non c'è tabella dei montaggi); guardare dentro un UNC vorrebbe dire interrogare la rete, e un nome `.invalid` (RFC 6761) non risponde mai |
| 2026-10-20 | `TestLibrary.LoseDatabaseAsync`: su Windows un'eliminazione che trova il file in uso da un altro programma (`0x80070020`) si ripete ogni 50 ms, per al più 5 s | Su Windows un file aperto da un altro programma non si elimina. Su questo PC, con Defender attivo, succedeva circa 3 volte su 40 esecuzioni di `Febe.Tests.Library`: il file era libero dopo 6–17 ms e il Restart Manager non vedeva nessun processo che lo tenesse, quindi non è un collegamento di Febe rimasto aperto. Su Linux eliminare un file aperto riesce sempre e non si ripete nulla |
| 2026-10-20 | Prova di `costruisci.sh`: su Windows prima Git Bash (accanto a git sul PATH, poi nelle cartelle del suo installatore), altrimenti un bash sul PATH che non sia il lanciatore di WSL (`System32\bash.exe`, alias in `WindowsApps`); senza bash la prova è inconcludente invece di passare in silenzio | Dal PATH di PowerShell il primo bash è il lanciatore di WSL, che senza distribuzione fallisce («execvpe(/bin/bash) failed») e non vede lo script col percorso di Windows; su Linux si usa come prima il primo bash sul PATH |
+3 -1
View File
@@ -15,7 +15,9 @@ public sealed class HostingTests
var args = ChromiumCommandLine.Build(Options, new ChromiumLaunchOptions());
CollectionAssert.Contains(args.ToList(), "--remote-debugging-port=9333");
CollectionAssert.Contains(args.ToList(), "--user-data-dir=/tmp/febe-profilo");
// The profile reaches Chromium as a full path: «/tmp/febe-profilo» on Linux, rooted on the current drive on Windows.
CollectionAssert.Contains(args.ToList(), $"--user-data-dir={Path.GetFullPath(Options.ProfileDirectory)}");
CollectionAssert.Contains(args.ToList(), "--no-first-run");
CollectionAssert.Contains(args.ToList(), "--no-default-browser-check");
CollectionAssert.Contains(args.ToList(), "--window-size=1280,900");
+55 -7
View File
@@ -112,10 +112,10 @@ public sealed partial class InstallerTests
StringAssert.Contains(text, "100 * 1024 * 1024");
Assert.DoesNotContain("\r\n", text, "Unix line ends: bash would choke on CR");
var bash = FindOnPath("bash");
var bash = FindBash();
if (bash is null)
{
return;
Assert.Inconclusive("Manca bash (su Windows: Git Bash): la prova della sintassi di costruisci.sh si salta.");
}
using var process = Process.Start(new ProcessStartInfo(bash, ["-n", script]) { RedirectStandardError = true })!;
@@ -124,21 +124,69 @@ public sealed partial class InstallerTests
Assert.AreEqual(0, process.ExitCode, errors);
}
private static string? FindOnPath(string name)
private static string? FindOnPath(string name) => OnPath(name).FirstOrDefault();
/// <summary>
/// A bash that checks the script on this system. Elsewhere than Windows, the first on PATH. On Windows Git Bash
/// first (next to git on PATH, then where its installer puts it), else any bash on PATH except the WSL launcher:
/// <c>System32\bash.exe</c> and the <c>WindowsApps</c> alias start a Linux distribution, which may be missing
/// («execvpe(/bin/bash) failed») and does not see the script by its Windows path.
/// </summary>
private static string? FindBash()
{
if (!OperatingSystem.IsWindows())
{
return FindOnPath("bash");
}
var roots = new List<string>();
if (FindOnPath("git") is { } git)
{
// git.exe sits in <Git>\cmd, <Git>\bin or <Git>\mingw64\bin.
for (var folder = Path.GetDirectoryName(git); folder is not null && roots.Count < 3; folder = Path.GetDirectoryName(folder))
{
roots.Add(folder);
}
}
foreach (var variable in new[] { "ProgramW6432", "ProgramFiles", "ProgramFiles(x86)" })
{
if (Environment.GetEnvironmentVariable(variable) is { Length: > 0 } programs)
{
roots.Add(Path.Combine(programs, "Git"));
}
}
roots.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Programs", "Git"));
var gitBash = roots
.SelectMany(root => new[] { Path.Combine(root, "bin", "bash.exe"), Path.Combine(root, "usr", "bin", "bash.exe") })
.FirstOrDefault(path => File.Exists(path) && !IsWslLauncher(path));
return gitBash ?? OnPath("bash").FirstOrDefault(path => !IsWslLauncher(path));
}
private static bool IsWslLauncher(string path)
{
var full = Path.GetFullPath(path);
var windows = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
return (windows.Length > 0 && full.StartsWith(Path.TrimEndingDirectorySeparator(windows) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
|| full.Contains(@"\Microsoft\WindowsApps\", StringComparison.OrdinalIgnoreCase);
}
/// <summary>Every file called <paramref name="name"/> on PATH, in order (on Windows only <c>.exe</c>: the others do not start).</summary>
private static IEnumerable<string> OnPath(string name)
{
var candidates = OperatingSystem.IsWindows() ? new[] { name + ".exe" } : new[] { name, name + ".exe" };
foreach (var folder in (Environment.GetEnvironmentVariable("PATH") ?? string.Empty).Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries))
{
foreach (var candidate in new[] { name, name + ".exe" })
foreach (var candidate in candidates)
{
var path = Path.Combine(folder, candidate);
if (File.Exists(path))
{
return path;
yield return path;
}
}
}
return null;
}
[GeneratedRegex(@"^\s*(?:Delete|RMDir)(?:\s+/\w+)*\s+""(?<target>[^""]+)""", RegexOptions.Multiline)]
@@ -27,7 +27,8 @@ public sealed class ImportSourcesTests
Assert.AreEqual(Path.Combine(root, "4K Stogram"), info.FullPath);
Assert.IsTrue(info.ReadOnly, "Il volume /importa è in sola lettura.");
Assert.IsFalse(info.CanMove);
Assert.AreEqual(root + "/4K Stogram", info.DisplayPath);
// Shown as in the container, with «/»: the same text as the root on Linux; on Windows the separators change too.
Assert.AreEqual(LibraryLayout.ToStored(root) + "/4K Stogram", info.DisplayPath);
var outside = Assert.ThrowsExactly<ImportSourceException>(() => sources.Inspect(temp.Combine("fuori")));
StringAssert.Contains(outside.Message, "sottocartella");
+13 -4
View File
@@ -99,14 +99,23 @@ public sealed class StartupProblemTests
[TestMethod]
public async Task ADataFolderOnANetworkShareIsRefused()
{
// A share shows itself differently on the two systems: on Linux as a cifs mount in the mount table (injected
// here), on Windows as a UNC path, recognised from its form before anything touches it. The Windows server name
// ends in .invalid (RFC 6761): no machine answers to it, and nothing here looks it up.
using var temp = new TempFolder("server-problemi");
var data = temp.Combine("dati");
var windows = OperatingSystem.IsWindows();
var data = windows ? @"\\febe-prova.invalid\condivisa\dati" : temp.Combine("dati");
var mounts = $"/dev/sda1 / ext4 rw 0 0\n//nas/condivisa {temp.Path} cifs rw 0 0\n";
await using var server = await FebeServer.StartAsync(Options(temp), Hooks() with { DataFolderCheck = new DataFolderCheck(() => mounts) });
await using var server = await FebeServer.StartAsync(Options(temp) with { DataFolder = data }, Hooks() with { DataFolderCheck = new DataFolderCheck(() => mounts) });
var problem = server.Problems.Single();
Assert.AreEqual(StartupChecks.DataOnNetwork, problem.Code);
StringAssert.Contains(problem.Message, "cifs");
Assert.IsFalse(Directory.Exists(Path.Combine(data, "registro")));
StringAssert.Contains(problem.Message, windows ? "condivisione di rete" : "cifs");
if (!windows)
{
// Nothing written in the Data folder (on Windows the share does not exist: looking would mean asking the network).
Assert.IsFalse(Directory.Exists(Path.Combine(data, "registro")));
}
using var client = Client(server);
await AssertHealthAsync(client, HttpStatusCode.ServiceUnavailable, """{"stato":"problema"}""");
}
+24 -1
View File
@@ -63,13 +63,36 @@ internal sealed class TestLibrary : IAsyncDisposable
await Db.DisposeAsync();
foreach (var suffix in new[] { string.Empty, "-wal", "-shm" })
{
File.Delete(Data.Database + suffix);
await DeleteClosedFileAsync(Data.Database + suffix);
}
Db = await FebeDatabase.OpenAsync(Data.Root);
Ingest = new LibraryIngest(Db, Layout, LibraryNaming.Default, Journal, Clock, Thumbnails, Index);
}
/// <summary>
/// Deletes a file Febe has already closed. On Windows a file still held open elsewhere cannot be deleted, and on one PC a
/// database just closed was now and then held for a few milliseconds by something outside Febe (Restart Manager listed
/// no process; probably the real-time antivirus, which was active, but the cause was never shown): that sharing
/// violation is waited out (at most 5 s). On Linux a delete never meets one, so the first attempt is the only one.
/// </summary>
private static async Task DeleteClosedFileAsync(string path)
{
const int SharingViolation = unchecked((int)0x80070020);
for (var attempt = 1; ; attempt++)
{
try
{
File.Delete(path);
return;
}
catch (IOException ex) when (OperatingSystem.IsWindows() && ex.HResult == SharingViolation && attempt < 100)
{
await Task.Delay(50);
}
}
}
public ValueTask DisposeAsync() => Db.DisposeAsync();
}
+4 -2
View File
@@ -163,10 +163,12 @@ public sealed class ImportApiTests
Assert.AreEqual(HttpStatusCode.BadRequest, sources, "desktop: the native picker, no listing");
}
// Docker: the sources live under /importa (absent on this machine: the listing says so).
// Docker: the sources live under /importa (absent on this machine: the listing says so). The root is reported as
// a full path: «/importa» in the container, rooted on the current drive where the edition runs for development
// on Windows.
await using var docker = await Part2.StartAsync();
var overview = await docker.GetJsonAsync("/api/import");
Assert.AreEqual("/importa", overview.Str("sourceRoot"));
Assert.AreEqual(Path.GetFullPath("/importa"), overview.Str("sourceRoot"));
Assert.IsFalse(overview.Bool("pickFolder"));
var (pick, _) = await docker.SendJsonAsync(HttpMethod.Post, "/api/import/pick-folder");
Assert.AreEqual(HttpStatusCode.BadRequest, pick);