mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 06:52:56 +08:00
Add migration to reset and repopulate existing skin hashes
This commit is contained in:
parent
5f53dd8021
commit
9e6e41d7c0
@ -32,7 +32,7 @@ namespace osu.Game.Database
|
|||||||
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
||||||
public abstract class ArchiveModelManager<TModel, TFileModel> : IModelManager<TModel>, IModelFileManager<TModel, TFileModel>
|
public abstract class ArchiveModelManager<TModel, TFileModel> : IModelManager<TModel>, IModelFileManager<TModel, TFileModel>
|
||||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
||||||
where TFileModel : class, INamedFileInfo, new()
|
where TFileModel : class, INamedFileInfo, IHasPrimaryKey, new()
|
||||||
{
|
{
|
||||||
private const int import_queue_request_concurrency = 1;
|
private const int import_queue_request_concurrency = 1;
|
||||||
|
|
||||||
@ -520,10 +520,13 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
Files.Dereference(file.FileInfo);
|
Files.Dereference(file.FileInfo);
|
||||||
|
|
||||||
|
if (file.ID > 0)
|
||||||
|
{
|
||||||
// This shouldn't be required, but here for safety in case the provided TModel is not being change tracked
|
// This shouldn't be required, but here for safety in case the provided TModel is not being change tracked
|
||||||
// Definitely can be removed once we rework the database backend.
|
// Definitely can be removed once we rework the database backend.
|
||||||
usage.Context.Set<TFileModel>().Remove(file);
|
usage.Context.Set<TFileModel>().Remove(file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
model.Files.Remove(file);
|
model.Files.Remove(file);
|
||||||
}
|
}
|
||||||
|
23
osu.Game/Migrations/20211020081609_ResetSkinHashes.cs
Normal file
23
osu.Game/Migrations/20211020081609_ResetSkinHashes.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using osu.Game.Database;
|
||||||
|
|
||||||
|
namespace osu.Game.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(OsuDbContext))]
|
||||||
|
[Migration("20211020081609_ResetSkinHashes")]
|
||||||
|
public partial class ResetSkinHashes : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.Sql($"UPDATE SkinInfo SET Hash = null");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.OpenGL.Textures;
|
using osu.Framework.Graphics.OpenGL.Textures;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
@ -84,6 +85,27 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
SourceChanged?.Invoke();
|
SourceChanged?.Invoke();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// can be removed 20220420.
|
||||||
|
populateMissingHashes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateMissingHashes()
|
||||||
|
{
|
||||||
|
var skinsWithoutHashes = ModelStore.ConsumableItems.Where(i => i.Hash == null).ToArray();
|
||||||
|
|
||||||
|
foreach (SkinInfo skin in skinsWithoutHashes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Update(skin);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Delete(skin);
|
||||||
|
Logger.Error(e, $"Existing skin {skin} has been deleted during hash recomputation due to being invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osk";
|
protected override bool ShouldDeleteArchive(string path) => Path.GetExtension(path)?.ToLowerInvariant() == ".osk";
|
||||||
|
Loading…
Reference in New Issue
Block a user