diff --git a/packages/fuse-client/syscalls/chmod.ts b/packages/fuse-client/syscalls/chmod.ts index 05817cb..342112b 100644 --- a/packages/fuse-client/syscalls/chmod.ts +++ b/packages/fuse-client/syscalls/chmod.ts @@ -8,6 +8,12 @@ export const chmod: (backend: SQLiteBackend) => MountOptions["chmod"] = ( ) => { return async (path, mode, cb) => { console.info("chmod(%s, %d)", path, mode); + + if (backend.isVirtualFile(path)) { + cb(0); + return; + } + const r = await backend.updateMode(path, mode); match(r) .with({ status: "ok" }, () => { diff --git a/packages/fuse-client/syscalls/rename.ts b/packages/fuse-client/syscalls/rename.ts index 2b4a2e9..75bc703 100644 --- a/packages/fuse-client/syscalls/rename.ts +++ b/packages/fuse-client/syscalls/rename.ts @@ -6,6 +6,13 @@ export const rename: (backend: SQLiteBackend) => MountOptions["rename"] = ( ) => { return async (srcPath, destPath, cb) => { console.info("rename(%s, %s)", srcPath, destPath); + + if (backend.isVirtualFile(srcPath)) { + await backend.createFile(destPath, "file", 33188, 0, 0); + cb(0); + return; + } + const r = await backend.renameFile(srcPath, destPath); if (r.status === "ok") { cb(0); diff --git a/packages/fuse-client/syscalls/truncate.ts b/packages/fuse-client/syscalls/truncate.ts index 5f8f9f8..20226aa 100644 --- a/packages/fuse-client/syscalls/truncate.ts +++ b/packages/fuse-client/syscalls/truncate.ts @@ -7,6 +7,12 @@ export const truncate: (backend: SQLiteBackend) => MountOptions["truncate"] = ( ) => { return async (path, size, cb) => { console.info("truncate(%s, %d)", path, size); + + if (backend.isVirtualFile(path)) { + cb(0); + return; + } + const r = await backend.truncateFile(path, size); await match(r) .with({ status: "ok" }, async (r) => { diff --git a/packages/fuse-client/syscalls/unlink.ts b/packages/fuse-client/syscalls/unlink.ts index 07985ef..0161f6b 100644 --- a/packages/fuse-client/syscalls/unlink.ts +++ b/packages/fuse-client/syscalls/unlink.ts @@ -6,6 +6,12 @@ export const unlink: (backend: SQLiteBackend) => MountOptions["unlink"] = ( ) => { return async (path, cb) => { console.info("unlink(%s)", path); + + if (backend.isVirtualFile(path)) { + cb(0); + return; + } + const r = await backend.deleteFile(path); if (r.status === "ok") { cb(0); diff --git a/packages/fuse-client/syscalls/write.ts b/packages/fuse-client/syscalls/write.ts index f6ed0a2..4c8f38c 100644 --- a/packages/fuse-client/syscalls/write.ts +++ b/packages/fuse-client/syscalls/write.ts @@ -6,6 +6,13 @@ export const write: (backend: SQLiteBackend) => MountOptions["write"] = ( ) => { return async (path, fd, buf, len, pos, cb) => { console.info("write(%s, %d, %d, %d)", path, fd, len, pos); + + if (backend.isVirtualFile(path)) { + const chunk = Buffer.from(buf, pos, len); + cb(chunk.length); + return; + } + const chunk = Buffer.from(buf, pos, len); // TODO: This may throw (because of flush!, what should happen then?) await backend.write(path, { content: chunk, offset: pos, size: len }); diff --git a/packages/sqlite-backend/SQLiteBackend.ts b/packages/sqlite-backend/SQLiteBackend.ts index f1f9a3d..0d0714d 100644 --- a/packages/sqlite-backend/SQLiteBackend.ts +++ b/packages/sqlite-backend/SQLiteBackend.ts @@ -414,6 +414,7 @@ export class SQLiteBackend implements Backend { } async deleteFile(filepath: string) { + const links = await this.prisma.link.findMany(); try { const { link } = await this.prisma.$transaction(async (tx) => { const link = await this.prisma.link.findFirstOrThrow({