From 5ce97cd7bfadfc650dd034d9529ba152b3d64949 Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Wed, 7 May 2025 19:37:48 +0200 Subject: [PATCH] fix: fix cache --- docker-compose.yml | 5 +++++ src/wov.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1cdf784..450d9ff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,13 @@ services: - DISCORD_WEBHOOK_URL - DISCORD_MENTION - DISCORD_REWARDS_GIVER + volumes: + - cache:/app/.cache restart: always networks: web: external: true + +volumes: + cache: diff --git a/src/wov.ts b/src/wov.ts index 9306bf7..8325fe9 100644 --- a/src/wov.ts +++ b/src/wov.ts @@ -1,4 +1,5 @@ import { env } from "./env"; +import { mkdir } from "node:fs/promises"; export type QuestResult = { quest: { @@ -26,11 +27,12 @@ export const checkForNewQuest = async (): Promise => { const history = (await response.json()) as Array; const lastId = history[0].quest.id; - const cacheFile = Bun.file(".quest_cache"); + const cacheFile = Bun.file(".cache/.quest_cache"); + await mkdir(".cache", { recursive: true }); if ((await cacheFile.exists()) && (await cacheFile.text()) === lastId) { return null; } - cacheFile.write(lastId); + await cacheFile.write(lastId); return history[0]; };