mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 05:23:22 +08:00
Refetch local metadata cache if corruption is detected
Addresses one of the points in https://github.com/ppy/osu/issues/31496. Not going to lie, this is mostly best-effort stuff (while the refetch is happening, metadata lookups using the local source *will* fail), but I see this as a marginal scenario anyways.
This commit is contained in:
parent
75d1fab6d0
commit
b0c0c98c5d
@ -114,6 +114,15 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (SqliteException sqliteException) when (sqliteException.SqliteErrorCode == 11 || sqliteException.SqliteErrorCode == 26) // SQLITE_CORRUPT, SQLITE_NOTADB
|
||||||
|
{
|
||||||
|
// only attempt purge & refetch if there is no other refetch in progress
|
||||||
|
if (cacheDownloadRequest == null)
|
||||||
|
{
|
||||||
|
tryPurgeCache();
|
||||||
|
prepareLocalCache();
|
||||||
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logForModel(beatmapInfo.BeatmapSet, $@"Cached local retrieval for {beatmapInfo} failed with {ex}.");
|
logForModel(beatmapInfo.BeatmapSet, $@"Cached local retrieval for {beatmapInfo} failed with {ex}.");
|
||||||
@ -125,6 +134,22 @@ namespace osu.Game.Beatmaps
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tryPurgeCache()
|
||||||
|
{
|
||||||
|
log(@"Local metadata cache is corrupted; attempting purge.");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(storage.GetFullPath(cache_database_name));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
log($@"Failed to purge local metadata cache: {ex}");
|
||||||
|
}
|
||||||
|
|
||||||
|
log(@"Local metadata cache purged due to corruption.");
|
||||||
|
}
|
||||||
|
|
||||||
private SqliteConnection getConnection() =>
|
private SqliteConnection getConnection() =>
|
||||||
new SqliteConnection(string.Concat(@"Data Source=", storage.GetFullPath(@"online.db", true)));
|
new SqliteConnection(string.Concat(@"Data Source=", storage.GetFullPath(@"online.db", true)));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user