forked from Alaanor/beatlist
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a process to correct a bug when upgrading to v1.4.0
- Loading branch information
Showing
4 changed files
with
99 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import store from "@/plugins/store"; | ||
import BeatsaverCachedLibrary from "@/libraries/beatmap/repo/BeatsaverCachedLibrary"; | ||
import BeatmapLibrary from "@/libraries/beatmap/BeatmapLibrary"; | ||
import { | ||
BeatsaverKey, | ||
toStrKey, | ||
BeatsaverKeyType, | ||
} from "@/libraries/beatmap/repo/BeatsaverKeyType"; | ||
import BeatsaverCacheManager from "@/libraries/beatmap/repo/BeatsaverCacheManager"; | ||
import { BeatsaverItem } from "@/libraries/beatmap/repo/BeatsaverItem"; | ||
|
||
async function ReloadBeatsaverCache() { | ||
const beatmaps = BeatmapLibrary.GetAllValidMap(); | ||
const validCache = BeatsaverCachedLibrary.GetAllValid(); | ||
const invalidCache = BeatsaverCachedLibrary.GetAllInvalid(); | ||
|
||
const targetKeys: BeatsaverKey[] = []; | ||
for (const beatmap of beatmaps) { | ||
const hash = beatmap.hash?.toUpperCase(); | ||
if (hash == null) { | ||
// eslint-disable-next-line no-continue | ||
continue; | ||
} | ||
if (validCache.has(hash)) { | ||
// eslint-disable-next-line no-continue | ||
continue; | ||
} | ||
|
||
const beatsaverKey: BeatsaverKey = { | ||
type: BeatsaverKeyType.Hash, | ||
value: hash, | ||
}; | ||
const keyStr = toStrKey(beatsaverKey); | ||
if (!invalidCache.has(keyStr)) { | ||
targetKeys.push(beatsaverKey); | ||
} | ||
} | ||
if (targetKeys.length > 0) { | ||
const notCachedItems: { | ||
key: BeatsaverKey; | ||
item: BeatsaverItem; | ||
}[] = []; | ||
for (const beatsaverKey of targetKeys) { | ||
// eslint-disable-next-line no-await-in-loop | ||
const item = await BeatsaverCacheManager.forceGetCacheBeatmap( | ||
beatsaverKey, | ||
true | ||
); | ||
console.log(item); | ||
notCachedItems.push({ key: beatsaverKey, item }); | ||
} | ||
BeatsaverCachedLibrary.AddAll(notCachedItems); | ||
} | ||
} | ||
|
||
function ClearPlaylistCache() { | ||
store.commit("playlist/SET_PLAYLISTS", []); | ||
} | ||
|
||
export default async (clearPlaylistCache: boolean) => { | ||
await ReloadBeatsaverCache(); | ||
if (clearPlaylistCache) { | ||
ClearPlaylistCache(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters