mirror of
https://github.com/ppy/osu
synced 2024-12-16 03:45:46 +00:00
Merge pull request #17401 from peppy/update-date-added-on-use-existing
Fix beatmap date added not being updated on reimporting a soft deleted beatmap
This commit is contained in:
commit
056e568ffb
@ -590,6 +590,8 @@ namespace osu.Game.Tests.Database
|
||||
|
||||
Assert.IsTrue(imported.DeletePending);
|
||||
|
||||
var originalAddedDate = imported.DateAdded;
|
||||
|
||||
var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm);
|
||||
|
||||
// check the newly "imported" beatmap is actually just the restored previous import. since it matches hash.
|
||||
@ -597,6 +599,7 @@ namespace osu.Game.Tests.Database
|
||||
Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID);
|
||||
Assert.IsFalse(imported.DeletePending);
|
||||
Assert.IsFalse(importedSecondTime.DeletePending);
|
||||
Assert.That(importedSecondTime.DateAdded, Is.GreaterThan(originalAddedDate));
|
||||
});
|
||||
}
|
||||
|
||||
@ -646,6 +649,8 @@ namespace osu.Game.Tests.Database
|
||||
|
||||
Assert.IsTrue(imported.DeletePending);
|
||||
|
||||
var originalAddedDate = imported.DateAdded;
|
||||
|
||||
var importedSecondTime = await LoadOszIntoStore(importer, realm.Realm);
|
||||
|
||||
// check the newly "imported" beatmap is actually just the restored previous import. since it matches hash.
|
||||
@ -653,6 +658,7 @@ namespace osu.Game.Tests.Database
|
||||
Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID);
|
||||
Assert.IsFalse(imported.DeletePending);
|
||||
Assert.IsFalse(importedSecondTime.DeletePending);
|
||||
Assert.That(importedSecondTime.DateAdded, Is.GreaterThan(originalAddedDate));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -163,6 +163,12 @@ namespace osu.Game.Stores
|
||||
return existing.OnlineID == import.OnlineID && existingIds.SequenceEqual(importIds);
|
||||
}
|
||||
|
||||
protected override void UndeleteForReuse(BeatmapSetInfo existing)
|
||||
{
|
||||
base.UndeleteForReuse(existing);
|
||||
existing.DateAdded = DateTimeOffset.UtcNow;
|
||||
}
|
||||
|
||||
public override bool IsAvailableLocally(BeatmapSetInfo model)
|
||||
{
|
||||
return Realm.Run(realm => realm.All<BeatmapSetInfo>().Any(s => s.OnlineID == model.OnlineID));
|
||||
|
@ -351,7 +351,8 @@ namespace osu.Game.Stores
|
||||
|
||||
using (var transaction = realm.BeginWrite())
|
||||
{
|
||||
existing.DeletePending = false;
|
||||
if (existing.DeletePending)
|
||||
UndeleteForReuse(existing);
|
||||
transaction.Commit();
|
||||
}
|
||||
|
||||
@ -387,7 +388,9 @@ namespace osu.Game.Stores
|
||||
{
|
||||
LogForModel(item, @$"Found existing {HumanisedModelName} for {item} (ID {existing.ID}) – skipping import.");
|
||||
|
||||
existing.DeletePending = false;
|
||||
if (existing.DeletePending)
|
||||
UndeleteForReuse(existing);
|
||||
|
||||
transaction.Commit();
|
||||
|
||||
return existing.ToLive(Realm);
|
||||
@ -527,6 +530,15 @@ namespace osu.Game.Stores
|
||||
private bool checkAllFilesExist(TModel model) =>
|
||||
model.Files.All(f => Files.Storage.Exists(f.File.GetStoragePath()));
|
||||
|
||||
/// <summary>
|
||||
/// Called when an existing model is in a soft deleted state but being recovered.
|
||||
/// </summary>
|
||||
/// <param name="existing">The existing model.</param>
|
||||
protected virtual void UndeleteForReuse(TModel existing)
|
||||
{
|
||||
existing.DeletePending = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether this specified path should be removed after successful import.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user