When deleting beatmaps, remove their MD5 hashes from the lookup table.

Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
Jeffrey Han 2015-09-02 14:37:16 -05:00
parent d5154b567e
commit 396071dfbc
2 changed files with 13 additions and 5 deletions

View File

@ -64,6 +64,9 @@ public class Beatmap implements Comparable<Beatmap> {
/** The OSU File object associated with this beatmap. */ /** The OSU File object associated with this beatmap. */
private File file; private File file;
/** MD5 hash of this file. */
public String md5Hash;
/** /**
* [General] * [General]
*/ */
@ -203,9 +206,6 @@ public class Beatmap implements Comparable<Beatmap> {
/** Slider border color. If null, the skin value is used. */ /** Slider border color. If null, the skin value is used. */
public Color sliderBorder; public Color sliderBorder;
/** MD5 hash of this file. */
public String md5Hash;
/** /**
* [HitObjects] * [HitObjects]
*/ */

View File

@ -164,12 +164,18 @@ public class BeatmapSetList {
} }
// remove all node references // remove all node references
Beatmap beatmap = node.getBeatmapSet().get(0); BeatmapSet beatmapSet = node.getBeatmapSet();
Beatmap beatmap = beatmapSet.get(0);
nodes.remove(index); nodes.remove(index);
parsedNodes.remove(eCur); parsedNodes.remove(eCur);
mapCount -= node.getBeatmapSet().size(); mapCount -= beatmapSet.size();
if (beatmap.beatmapSetID > 0) if (beatmap.beatmapSetID > 0)
MSIDdb.remove(beatmap.beatmapSetID); MSIDdb.remove(beatmap.beatmapSetID);
for (int i = 0, n = beatmapSet.size(); i < n; i++) {
Beatmap bm = beatmapSet.get(i);
if (bm.md5Hash != null)
this.beatmapHashDB.remove(bm.md5Hash);
}
// reset indices // reset indices
for (int i = index, size = size(); i < size; i++) for (int i = index, size = size(); i < size; i++)
@ -241,6 +247,8 @@ public class BeatmapSetList {
// remove song reference // remove song reference
Beatmap beatmap = node.getBeatmapSet().remove(node.beatmapIndex); Beatmap beatmap = node.getBeatmapSet().remove(node.beatmapIndex);
mapCount--; mapCount--;
if (beatmap.md5Hash != null)
beatmapHashDB.remove(beatmap.md5Hash);
// re-link nodes // re-link nodes
if (node.prev != null) if (node.prev != null)