diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 952ac08..bdbd4d9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -128,6 +128,7 @@ jobs: GITEA_INTERNAL_URL: http://127.0.0.1:3000 GITEA_ORG: giersig.eu OG_CACHE_DIR: /usr/local/git/.cache/og + UNFURL_CACHE_DIR: /usr/local/git/.cache/unfurl - name: Deploy via rsync run: | diff --git a/eleventy.config.js b/eleventy.config.js index 44f3e2d..628bb8c 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -1854,7 +1854,9 @@ export default function (eleventyConfig) { // prefetchUrl() already caches responses on disk; re-calling it for known URLs // is pure overhead. Writing [...urls] (not [...seen, ...newUrls]) intentionally // prunes URLs from soft-deleted posts, preventing unbounded manifest growth. - const manifestPath = resolve(__dirname, ".cache", "unfurl-manifest.json"); + const manifestPath = process.env.UNFURL_CACHE_DIR + ? resolve(process.env.UNFURL_CACHE_DIR, "manifest.json") + : resolve(__dirname, ".cache", "unfurl-manifest.json"); let seen = new Set(); try { seen = new Set(JSON.parse(readFileSync(manifestPath, "utf-8"))); diff --git a/lib/unfurl-shortcode.js b/lib/unfurl-shortcode.js index 67dac41..7ceeb0b 100644 --- a/lib/unfurl-shortcode.js +++ b/lib/unfurl-shortcode.js @@ -3,7 +3,7 @@ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs"; import { resolve } from "path"; import { createHash } from "crypto"; -const CACHE_DIR = resolve(import.meta.dirname, "..", ".cache", "unfurl"); +const CACHE_DIR = process.env.UNFURL_CACHE_DIR || resolve(import.meta.dirname, "..", ".cache", "unfurl"); const CACHE_DURATION_MS = 7 * 24 * 60 * 60 * 1000; // 1 week const FAILURE_CACHE_MS = 7 * 24 * 60 * 60 * 1000; // 1 week — YouTube/bot-blocked sites never succeed, no point retrying daily const USER_AGENT = "Mozilla/5.0 (compatible; Indiekit/1.0; +https://getindiekit.com)";