compare metdata and remove duplicate from beatmap to prevent redundant storage

This commit is contained in:
Aergwyn 2017-11-23 19:46:58 +01:00
parent 0df5432f5e
commit e3a230320a
2 changed files with 22 additions and 0 deletions

View File

@ -515,6 +515,10 @@ private BeatmapSetInfo importToStorage(FileStore files, BeatmapStore beatmaps, A
if (existing == null)
{
// Exclude beatmap-metadata if it's equal to beatmapset-metadata
if (metadata.Equals(beatmap.Metadata))
beatmap.BeatmapInfo.Metadata = null;
RulesetInfo ruleset = rulesets.GetRuleset(beatmap.BeatmapInfo.RulesetID);
// TODO: this should be done in a better place once we actually need to dynamically update it.

View File

@ -66,5 +66,23 @@ public string AuthorString
Source,
Tags
}.Where(s => !string.IsNullOrEmpty(s)).ToArray();
public override bool Equals(object other)
{
var otherMetadata = other as BeatmapMetadata;
if (otherMetadata == null) return false;
return (onlineBeatmapSetID?.Equals(otherMetadata.onlineBeatmapSetID) ?? false)
&& (Title?.Equals(otherMetadata.Title) ?? false)
&& (TitleUnicode?.Equals(otherMetadata.TitleUnicode) ?? false)
&& (Artist?.Equals(otherMetadata.Artist) ?? false)
&& (ArtistUnicode?.Equals(otherMetadata.ArtistUnicode) ?? false)
&& (AuthorString?.Equals(otherMetadata.AuthorString) ?? false)
&& (Source?.Equals(otherMetadata.Source) ?? false)
&& (Tags?.Equals(otherMetadata.Tags) ?? false)
&& PreviewTime.Equals(otherMetadata.PreviewTime)
&& (AudioFile?.Equals(otherMetadata.AudioFile) ?? false)
&& (BackgroundFile?.Equals(otherMetadata.BackgroundFile) ?? false);
}
}
}