Merge pull request #1090 from tgi74/master

Fix replays crashing and not finding their associated beatmap
This commit is contained in:
Dean Herbert
2017-08-22 12:59:49 +09:00
committed by GitHub
5 changed files with 16 additions and 4 deletions

View File

@ -49,9 +49,16 @@ namespace osu.Game.Beatmaps
public string Path { get; set; } public string Path { get; set; }
[JsonProperty("file_md5")] [JsonProperty("file_sha2")]
public string Hash { get; set; } public string Hash { get; set; }
/// <summary>
/// MD5 is kept for legacy support (matching against replays, osu-web-10 etc.).
/// </summary>
[Indexed]
[JsonProperty("file_md5")]
public string MD5Hash { get; set; }
// General // General
public int AudioLeadIn { get; set; } public int AudioLeadIn { get; set; }
public bool Countdown { get; set; } public bool Countdown { get; set; }

View File

@ -372,6 +372,7 @@ namespace osu.Game.Beatmaps
beatmap.BeatmapInfo.Path = name; beatmap.BeatmapInfo.Path = name;
beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash(); beatmap.BeatmapInfo.Hash = ms.ComputeSHA2Hash();
beatmap.BeatmapInfo.MD5Hash = ms.ComputeMD5Hash();
// TODO: Diff beatmap metadata with set metadata and leave it here if necessary // TODO: Diff beatmap metadata with set metadata and leave it here if necessary
beatmap.BeatmapInfo.Metadata = null; beatmap.BeatmapInfo.Metadata = null;

View File

@ -20,7 +20,7 @@ namespace osu.Game.Beatmaps
/// The current version of this store. Used for migrations (see <see cref="PerformMigration(int, int)"/>). /// The current version of this store. Used for migrations (see <see cref="PerformMigration(int, int)"/>).
/// The initial version is 1. /// The initial version is 1.
/// </summary> /// </summary>
protected override int StoreVersion => 2; protected override int StoreVersion => 3;
public BeatmapStore(SQLiteConnection connection) public BeatmapStore(SQLiteConnection connection)
: base(connection) : base(connection)
@ -77,6 +77,10 @@ namespace osu.Game.Beatmaps
// cannot migrate; breaking underlying changes. // cannot migrate; breaking underlying changes.
Reset(); Reset();
break; break;
case 3:
// Added MD5Hash column to BeatmapInfo
Connection.MigrateTable<BeatmapInfo>();
break;
} }
} }
} }

View File

@ -109,7 +109,7 @@ namespace osu.Game
dependencies.Cache(RulesetStore = new RulesetStore(connection)); dependencies.Cache(RulesetStore = new RulesetStore(connection));
dependencies.Cache(FileStore = new FileStore(connection, Host.Storage)); dependencies.Cache(FileStore = new FileStore(connection, Host.Storage));
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, connection, RulesetStore, Host)); dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, connection, RulesetStore, Host));
dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, connection, Host, BeatmapManager)); dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, connection, Host, BeatmapManager, RulesetStore));
dependencies.Cache(KeyBindingStore = new KeyBindingStore(connection, RulesetStore)); dependencies.Cache(KeyBindingStore = new KeyBindingStore(connection, RulesetStore));
dependencies.Cache(new OsuColour()); dependencies.Cache(new OsuColour());

View File

@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Scoring
var version = sr.ReadInt32(); var version = sr.ReadInt32();
/* score.FileChecksum = */ /* score.FileChecksum = */
var beatmapHash = sr.ReadString(); var beatmapHash = sr.ReadString();
score.Beatmap = beatmaps.QueryBeatmap(b => b.Hash == beatmapHash); score.Beatmap = beatmaps.QueryBeatmap(b => b.MD5Hash == beatmapHash);
/* score.PlayerName = */ /* score.PlayerName = */
sr.ReadString(); sr.ReadString();
/* var localScoreChecksum = */ /* var localScoreChecksum = */