fix: prevent double asset update
This commit is contained in:
+1
-2
@@ -18,7 +18,7 @@ export class AssetManager {
|
|||||||
const [avatars, weapons, relics] = await Promise.all([
|
const [avatars, weapons, relics] = await Promise.all([
|
||||||
getEnkaAvatarStore(),
|
getEnkaAvatarStore(),
|
||||||
getEnkaWeaponStore(),
|
getEnkaWeaponStore(),
|
||||||
await getEnkaRelicStore(),
|
getEnkaRelicStore(),
|
||||||
]);
|
]);
|
||||||
return [
|
return [
|
||||||
...Object.values(avatars).flatMap((a) => [
|
...Object.values(avatars).flatMap((a) => [
|
||||||
@@ -58,7 +58,6 @@ export class AssetManager {
|
|||||||
.then((d) => write(join("store", hash(name).toString(36)), d));
|
.then((d) => write(join("store", hash(name).toString(36)), d));
|
||||||
|
|
||||||
console.log("All missing assets fetched and stored");
|
console.log("All missing assets fetched and stored");
|
||||||
this.purgeExtraAssets();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async purgeExtraAssets() {
|
async purgeExtraAssets() {
|
||||||
|
|||||||
+17
-4
@@ -39,11 +39,24 @@ const font = file(fontFile);
|
|||||||
const iconFont = file(iconFontFile);
|
const iconFont = file(iconFontFile);
|
||||||
const shade = file(shadeSvg);
|
const shade = file(shadeSvg);
|
||||||
|
|
||||||
queueMicrotask(async () => {
|
var purging = false;
|
||||||
assets.getMissingAssets();
|
|
||||||
|
|
||||||
setInterval(() => {
|
queueMicrotask(() => {
|
||||||
assets.getMissingAssets();
|
if (purging) return;
|
||||||
|
purging = true;
|
||||||
|
assets.getMissingAssets().finally(() => (purging = false));
|
||||||
|
|
||||||
|
setInterval(async () => {
|
||||||
|
if (purging) return;
|
||||||
|
purging = true;
|
||||||
|
try {
|
||||||
|
await assets.getMissingAssets();
|
||||||
|
await assets.purgeExtraAssets();
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
} finally {
|
||||||
|
purging = false;
|
||||||
|
}
|
||||||
}, 86400000); // refresh assets every 24 hours
|
}, 86400000); // refresh assets every 24 hours
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user