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:
commit
5dc9b4c6ae
7 files changed
+105
-16
No files matched your search
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user