generated from polymech/site-template
Synced from site
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
// @ts-check
|
||||
import fs from "node:fs";
|
||||
import { fsCachePath } from "../../utils/runtimeChecks.js";
|
||||
|
||||
export async function getCachedBuffer(hash, image) {
|
||||
const cacheFilePath = fsCachePath + hash;
|
||||
|
||||
if (fs.existsSync(cacheFilePath)) {
|
||||
return fs.promises.readFile(cacheFilePath);
|
||||
}
|
||||
|
||||
const buffer = await image.clone().toBuffer();
|
||||
|
||||
await fs.promises.writeFile(cacheFilePath, buffer);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
// @ts-check
|
||||
import fs from "node:fs";
|
||||
import { fsCachePath } from "../../utils/runtimeChecks.js";
|
||||
|
||||
export async function getCachedBuffer(hash, image) {
|
||||
const cacheFilePath = fsCachePath + hash;
|
||||
|
||||
if (fs.existsSync(cacheFilePath)) {
|
||||
return fs.promises.readFile(cacheFilePath);
|
||||
}
|
||||
|
||||
const buffer = await image.clone().toBuffer();
|
||||
|
||||
await fs.promises.writeFile(cacheFilePath, buffer);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user