From 7da94c4010615896af90e784a32cd0d8a270af28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 7 Aug 2025 10:22:01 +0200 Subject: [PATCH] Fix metadata cache refetches failing on windows Reported at https://discord.com/channels/188630481301012481/1097318920991559880/1402910684320108574 among others. Only really visible on windows for reasons outlined in inline comment. --- osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs b/osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs index 8a91b688c2..b759619c06 100644 --- a/osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs +++ b/osu.Game/Beatmaps/LocalCachedBeatmapMetadataSource.cs @@ -192,6 +192,13 @@ namespace osu.Game.Beatmaps { try { + // `SqliteConnection` by default uses pooling. + // disposing an `SqliteConnection` is not enough to get `Microsoft.Data.Sqlite` to close the database file. + // this means that overwriting the file may fail if the pools are not cleared before trying. + // this fails especially loudly on Windows because of Windows file delete semantics being exclusive-write + // rather than Unix's "file is marked for deletion after last reader closes the fd". + SqliteConnection.ClearAllPools(); + using (var stream = File.OpenRead(cacheDownloadRequest.Filename)) using (var outStream = File.OpenWrite(cacheFilePath)) {