mirror of
https://github.com/ppy/osu
synced 2025-01-05 13:50:03 +00:00
Speed up startup cleanup operations.
This commit is contained in:
parent
3b1166d1e6
commit
6eb960010f
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Database;
|
||||
using SQLite.Net;
|
||||
using SQLiteNetExtensions.Extensions;
|
||||
@ -130,23 +129,11 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
private void cleanupPendingDeletions()
|
||||
{
|
||||
foreach (var b in QueryAndPopulate<BeatmapSetInfo>(b => b.DeletePending && !b.Protected))
|
||||
Connection.RunInTransaction(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// many-to-many join table entries are not automatically tidied.
|
||||
Connection.Table<BeatmapSetFileInfo>().Delete(f => f.BeatmapSetInfoID == b.ID);
|
||||
foreach (var b in QueryAndPopulate<BeatmapSetInfo>(b => b.DeletePending && !b.Protected))
|
||||
Connection.Delete(b, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, $@"Could not delete beatmap {b}");
|
||||
}
|
||||
}
|
||||
|
||||
//this is required because sqlite migrations don't work, initially inserting nulls into this field.
|
||||
//see https://github.com/praeclarum/sqlite-net/issues/326
|
||||
Connection.Query<BeatmapSetInfo>("UPDATE BeatmapSetInfo SET DeletePending = 0 WHERE DeletePending IS NULL");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,18 +140,21 @@ namespace osu.Game.IO
|
||||
|
||||
private void deletePending()
|
||||
{
|
||||
foreach (var f in QueryAndPopulate<FileInfo>(f => f.ReferenceCount < 1))
|
||||
Connection.RunInTransaction(() =>
|
||||
{
|
||||
try
|
||||
foreach (var f in Query<FileInfo>(f => f.ReferenceCount < 1))
|
||||
{
|
||||
Connection.Delete(f);
|
||||
Storage.Delete(Path.Combine(prefix, f.StoragePath));
|
||||
try
|
||||
{
|
||||
Storage.Delete(Path.Combine(prefix, f.StoragePath));
|
||||
Connection.Delete(f);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, $@"Could not delete beatmap {f}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error(e, $@"Could not delete beatmap {f}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user