This commit is contained in:
seb
2026-10-03 23:13:40 +02:00
parent 6520665dcf
commit 3b74c12f4e
36 changed files with 3669 additions and 2183 deletions

View File

@@ -180,6 +180,31 @@ export class BetterSqlite3Executor {
await safeDeleteByHash(join(this.storageDir, 'thumbavif'), hash);
}
async writeVfsContent(id, buffer) {
if (!this.storageDir || !id) return;
await safeWrite(join(this.storageDir, 'vfs', String(id)), buffer);
}
async readVfsContent(id) {
if (!this.storageDir || !id) return null;
try {
return await fsPromises.readFile(join(this.storageDir, 'vfs', String(id)));
} catch (err) {
if (err.code === 'ENOENT') return null;
throw err;
}
}
async deleteVfsContent(id) {
if (!this.storageDir || !id) return;
try {
await fsPromises.unlink(join(this.storageDir, 'vfs', String(id)));
} catch (err) {
if (err.code !== 'ENOENT') throw err;
}
}
async deletePic(hash) {
if (!this.storageDir || !hash) return;
await safeDeleteByHash(join(this.storageDir, 'fullbinary'), hash);
@@ -188,7 +213,7 @@ export class BetterSqlite3Executor {
async purgeFiles() {
if (!this.storageDir) return;
for (const sub of ['content', 'thumbavif', 'fullbinary', 'thumbbinary']) {
for (const sub of ['content', 'thumbavif', 'fullbinary', 'thumbbinary', 'vfs']) {
const dir = join(this.storageDir, sub);
try {
const files = await fsPromises.readdir(dir);
@@ -276,7 +301,7 @@ export class BetterSqlite3Provider extends BetterSqlite3Executor {
super(db, storageDir);
if (this.storageDir) {
for (const sub of ['content', 'thumbavif', 'fullbinary', 'thumbbinary']) {
for (const sub of ['content', 'thumbavif', 'fullbinary', 'thumbbinary', 'vfs']) {
mkdirSync(join(this.storageDir, sub), { recursive: true });
}
}
@@ -316,6 +341,9 @@ export class BetterSqlite3Provider extends BetterSqlite3Executor {
runner.readPicFull = executor.readPicFull.bind(executor);
runner.writePicThumb = executor.writePicThumb.bind(executor);
runner.readPicThumb = executor.readPicThumb.bind(executor);
runner.writeVfsContent = executor.writeVfsContent.bind(executor);
runner.readVfsContent = executor.readVfsContent.bind(executor);
runner.deleteVfsContent = executor.deleteVfsContent.bind(executor);
runner.deleteFile = executor.deleteFile.bind(executor);
runner.deletePic = executor.deletePic.bind(executor);
runner.purgeFiles = executor.purgeFiles.bind(executor);