From 8a324838467f113904e645e6510f68342f0b4f59 Mon Sep 17 00:00:00 2001 From: Donovan Daniels Date: Mon, 28 Dec 2020 03:23:44 -0600 Subject: [PATCH] cache file stuff (for refresh) --- src/Refresh.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Refresh.ts b/src/Refresh.ts index dfbbc42..42c3061 100644 --- a/src/Refresh.ts +++ b/src/Refresh.ts @@ -3,15 +3,18 @@ import * as fs from "fs-extra"; import E621Downloader from "e621downloader.js"; import progress from "cli-progress"; import ms from "e621downloader.js/build/src/util/Time"; +import path from "path"; export default class Refresh { static async run() { const cnf = ConfigManager.get(); if (!cnf.useCache) throw new TypeError("Cache is not enabled. Launch the app, go to settings, enable it, and download some tags."); - if (!fs.existsSync(`${cnf.saveDirectory}/cache.json`)) throw new TypeError("Cache file not found."); + const v = path.resolve(`${cnf.saveDirectory}${cnf.saveDirectory.endsWith("E621Downloader/Files") ? "/.." : ""}/cache.json`); + console.log("Looking for cache file at:", v); + if (!fs.existsSync(v)) throw new TypeError("Cache file not found."); const e = new E621Downloader({ ...cnf, - cacheFile: `${cnf.saveDirectory}/cache.json` + cacheFile: v }); const p = new progress.SingleBar({ hideCursor: true