@fre4x/grok 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42107,13 +42107,17 @@ var PersistentCache = class {
|
|
|
42107
42107
|
cacheDir;
|
|
42108
42108
|
memoryCache = /* @__PURE__ */ new Map();
|
|
42109
42109
|
onDiskWriteError;
|
|
42110
|
+
dirPromise;
|
|
42110
42111
|
constructor(namespace, options = {}) {
|
|
42111
42112
|
const baseDir = options.dir ?? process.env.FRE4X_CACHE_DIR ?? path.join(os.homedir(), ".fre4x-cache");
|
|
42112
42113
|
this.cacheDir = path.join(baseDir, namespace);
|
|
42113
42114
|
this.onDiskWriteError = options.onDiskWriteError;
|
|
42114
42115
|
}
|
|
42115
42116
|
async ensureDir() {
|
|
42116
|
-
|
|
42117
|
+
if (!this.dirPromise) {
|
|
42118
|
+
this.dirPromise = fs.mkdir(this.cacheDir, { recursive: true });
|
|
42119
|
+
}
|
|
42120
|
+
await this.dirPromise;
|
|
42117
42121
|
}
|
|
42118
42122
|
getFilePath(key) {
|
|
42119
42123
|
const safeKey = crypto.createHash("sha256").update(key).digest("hex");
|
|
@@ -42167,6 +42171,7 @@ var PersistentCache = class {
|
|
|
42167
42171
|
}
|
|
42168
42172
|
async clear() {
|
|
42169
42173
|
this.memoryCache.clear();
|
|
42174
|
+
this.dirPromise = void 0;
|
|
42170
42175
|
try {
|
|
42171
42176
|
await fs.rm(this.cacheDir, { recursive: true, force: true });
|
|
42172
42177
|
} catch {
|