From dfc0928ebe1af4fcb5b1837835d0b7642205526f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 20 Sep 2019 19:39:21 +0900 Subject: [PATCH] Fix scores importing with deleted beatmap sets --- osu.Game/Database/ArchiveModelManager.cs | 2 +- osu.Game/Scoring/Legacy/DatabasedLegacyScoreParser.cs | 2 +- osu.Game/Scoring/ScoreManager.cs | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index 6c79b0d472..2e30a7da3e 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -590,7 +590,7 @@ protected virtual void PreImport(TModel model) /// /// The existing model. /// The newly imported model. - /// Whether the existing model should be restored and used. Returning false will delete the existing a force a re-import. + /// Whether the existing model should be restored and used. Returning false will delete the existing and force a re-import. protected virtual bool CanUndelete(TModel existing, TModel import) => true; private DbSet queryModel() => ContextFactory.Get().Set(); diff --git a/osu.Game/Scoring/Legacy/DatabasedLegacyScoreParser.cs b/osu.Game/Scoring/Legacy/DatabasedLegacyScoreParser.cs index 77edd24612..2115d784a0 100644 --- a/osu.Game/Scoring/Legacy/DatabasedLegacyScoreParser.cs +++ b/osu.Game/Scoring/Legacy/DatabasedLegacyScoreParser.cs @@ -22,6 +22,6 @@ public DatabasedLegacyScoreParser(RulesetStore rulesets, BeatmapManager beatmaps } protected override Ruleset GetRuleset(int rulesetId) => rulesets.GetRuleset(rulesetId).CreateInstance(); - protected override WorkingBeatmap GetBeatmap(string md5Hash) => beatmaps.GetWorkingBeatmap(beatmaps.QueryBeatmap(b => b.MD5Hash == md5Hash)); + protected override WorkingBeatmap GetBeatmap(string md5Hash) => beatmaps.GetWorkingBeatmap(beatmaps.QueryBeatmap(b => !b.BeatmapSet.DeletePending && b.MD5Hash == md5Hash)); } } diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index 8475158c78..6da195cd7c 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -56,6 +56,8 @@ protected override ScoreInfo CreateModel(ArchiveReader archive) } } + protected override bool CanUndelete(ScoreInfo existing, ScoreInfo import) => false; + protected override IEnumerable GetStableImportPaths(Storage stableStorage) => stableStorage.GetFiles(ImportFromStablePath).Where(p => HandledExtensions.Any(ext => Path.GetExtension(p)?.Equals(ext, StringComparison.InvariantCultureIgnoreCase) ?? false));