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([
|
||||
getEnkaAvatarStore(),
|
||||
getEnkaWeaponStore(),
|
||||
await getEnkaRelicStore(),
|
||||
getEnkaRelicStore(),
|
||||
]);
|
||||
return [
|
||||
...Object.values(avatars).flatMap((a) => [
|
||||
@@ -58,7 +58,6 @@ export class AssetManager {
|
||||
.then((d) => write(join("store", hash(name).toString(36)), d));
|
||||
|
||||
console.log("All missing assets fetched and stored");
|
||||
this.purgeExtraAssets();
|
||||
}
|
||||
|
||||
async purgeExtraAssets() {
|
||||
|
||||
+17
-4
@@ -39,11 +39,24 @@ const font = file(fontFile);
|
||||
const iconFont = file(iconFontFile);
|
||||
const shade = file(shadeSvg);
|
||||
|
||||
queueMicrotask(async () => {
|
||||
assets.getMissingAssets();
|
||||
var purging = false;
|
||||
|
||||
setInterval(() => {
|
||||
assets.getMissingAssets();
|
||||
queueMicrotask(() => {
|
||||
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
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user