Skip to content

Commit

Permalink
chore: console.log to console.info
Browse files Browse the repository at this point in the history
  • Loading branch information
divyenduz committed Nov 1, 2023
1 parent 7a2f2f1 commit 3f7c0d4
Show file tree
Hide file tree
Showing 31 changed files with 46 additions and 33 deletions.
6 changes: 3 additions & 3 deletions packages/fuse-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,20 @@ export class FuseClient {
this.unmountFS(mountPath);
throw err;
}
console.log("filesystem mounted on " + mountPath);
console.info("filesystem mounted on " + mountPath);
}
);
}

unmountFS(mountPath: string) {
fuse.unmount(mountPath, (err) => {
if (err) {
console.log(
console.info(
"filesystem at " + mountPath + " not unmounted",
err.toString()
);
} else {
console.log("filesystem at " + mountPath + " unmounted");
console.info("filesystem at " + mountPath + " unmounted");
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const access: (backend: SQLiteBackend) => MountOptions["access"] = (
backend
) => {
return async (path, mode, cb) => {
console.log("access(%s, %d)", path, mode);
console.info("access(%s, %d)", path, mode);
cb(0);
};
};
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/chmod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const chmod: (backend: SQLiteBackend) => MountOptions["chmod"] = (
backend
) => {
return async (path, mode, cb) => {
console.log("chmod(%s, %d)", path, mode);
console.info("chmod(%s, %d)", path, mode);
const r = await backend.updateMode(path, mode);
match(r)
.with({ status: "ok" }, () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/chown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const chown: (backend: SQLiteBackend) => MountOptions["chown"] = (
backend
) => {
return async (path, uid, gid, cb) => {
console.log("chown(%s, %d, %d)", path, uid, gid);
console.info("chown(%s, %d, %d)", path, uid, gid);
cb(0);
};
};
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const create: (backend: SQLiteBackend) => MountOptions["create"] = (
backend
) => {
return async (path, mode, cb) => {
console.log("create(%s, %d)", path, mode);
console.info("create(%s, %d)", path, mode);

//@ts-expect-error fix types
const context = fuse.context();
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const destroy: (backend: SQLiteBackend) => MountOptions["destroy"] = (
backend
) => {
return async (cb) => {
console.log("destroy");
console.info("destroy");
cb(0);
};
};
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/fgetattr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const fgetattr: (backend: SQLiteBackend) => MountOptions["fgetattr"] = (
backend
) => {
return async (path, fd, cb) => {
console.log("fgetattr(%s, %d)", path, fd);
console.info("fgetattr -> getattr(%s, %d)", path, fd);
//@ts-expect-error fix types
// TODO: implement fgetattr properly
getattr(backend)?.(path, cb);
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/flush.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const flush: (backend: SQLiteBackend) => MountOptions["flush"] = (
backend
) => {
return async (path, fd, cb) => {
console.log("flush(%s, %d)", path, fd);
console.info("flush(%s, %d)", path, fd);
await backend.flush(path);
cb(0);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/fsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const fsync: (backend: SQLiteBackend) => MountOptions["fsync"] = (
backend
) => {
return async (path, fd, datasync, cb) => {
console.log("fsync(%s, %d, %d)", path, fd, datasync);
console.info("fsync -> flush(%s, %d, %d)", path, fd, datasync);
// @ts-expect-error TODO: implement fsync properly
// We do buffered writes and flush flushes the buffer!
// A program may not call flush but fsync without relenquishing fd (like SQLite)
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/fsyncdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const fsyncdir: (backend: SQLiteBackend) => MountOptions["fsyncdir"] = (
backend
) => {
return async (path, fd, datasync, cb) => {
console.log("fsyncdir(%s, %d, %d)", path, fd, datasync);
console.info("fsyncdir(%s, %d, %d)", path, fd, datasync);
cb(0);
};
};
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/ftruncate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const ftruncate: (
backend: SQLiteBackend
) => MountOptions["ftruncate"] = (backend) => {
return async (path, fd, size, cb) => {
console.log("ftruncate(%s, %d, %d)", path, fd, size);
console.info("ftruncate -> truncate(%s, %d, %d)", path, fd, size);
//@ts-expect-error fix types
// TODO: implement ftruncate properly
truncate(backend)(path, size, cb);
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/getxattr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const getxattr: (backend: SQLiteBackend) => MountOptions["getxattr"] = (
backend
) => {
return async (path, name, buffer, length, offset, cb) => {
console.log(
console.info(
"getxattr(%s, %s, %o, %d, %d)",
path,
name,
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/listxattr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const listxattr: (
backend: SQLiteBackend
) => MountOptions["listxattr"] = (backend) => {
return async (path, buffer, length, cb) => {
console.log("listxattr(%s, %d, %d)", path, buffer, length);
console.info("listxattr(%s, %d, %d)", path, buffer, length);
cb(0, 0);
};
};
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/mkdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const mkdir: (backend: SQLiteBackend) => MountOptions["mkdir"] = (
backend
) => {
return async (filepath, mode, cb) => {
console.log("mkdir(%s, %s)", filepath, mode);
console.info("mkdir(%s, %s)", filepath, mode);
const filename = path.parse(filepath).base;

if (filename.length > 255) {
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/mknod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const mknod: (backend: SQLiteBackend) => MountOptions["mknod"] = (
backend
) => {
return async (path, mode, dev, cb) => {
console.log("mknod(%s, %d, %d)", path, mode, dev);
console.info("mknod -> create(%s, %d, %d)", path, mode, dev);
//@ts-expect-error fix types
// TODO: implement mknod properly
create(backend)(path, mode, cb);
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const read: (backend: SQLiteBackend) => MountOptions["read"] = (
backend
) => {
return async (path, fd, buf, len, pos, cb) => {
console.log("read(%s, %d, %d, %d)", path, fd, len, pos);
console.info("read(%s, %d, %d, %d)", path, fd, len, pos);
const r = await backend.getFileChunks(fd, pos, len);
await match(r)
.with({ status: "ok" }, async (r) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/readdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const readdir: (backend: SQLiteBackend) => MountOptions["readdir"] = (
backend
) => {
return async (path, cb) => {
console.log("readdir(%s)", path);
console.info("readdir(%s)", path);

// TODO: figure out how are these directories in output of ls -la
const dotDirs = [".", ".."];
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const release: (backend: SQLiteBackend) => MountOptions["release"] = (
backend
) => {
return async (path, fd, cb) => {
console.log("release(%s, %d)", path, fd);
console.info("release(%s, %d)", path, fd);
cb(0);
};
};
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/releasedir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const releasedir: (
backend: SQLiteBackend
) => MountOptions["releasedir"] = (backend) => {
return async (path, fd, cb) => {
console.log("releasedir(%s, %d)", path, fd);
console.info("releasedir(%s, %d)", path, fd);
cb(0);
};
};
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/removexattr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const removexattr: (
backend: SQLiteBackend
) => MountOptions["removexattr"] = (backend) => {
return async (path, name, cb) => {
console.log("removexattr(%s, %s)", path, name);
console.info("removexattr(%s, %s)", path, name);
cb(0);
};
};
3 changes: 1 addition & 2 deletions packages/fuse-client/syscalls/rename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ export const rename: (backend: SQLiteBackend) => MountOptions["rename"] = (
backend
) => {
return async (srcPath, destPath, cb) => {
console.log("rename(%s, %s)", srcPath, destPath);
console.info("rename(%s, %s)", srcPath, destPath);
const r = await backend.renameFile(srcPath, destPath);
if (r.status === "ok") {
console.log("rename(%s, %s)", srcPath, destPath);
cb(0);
} else {
// TODO: can move fail, if yes, when?
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/rmdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const rmdir: (backend: SQLiteBackend) => MountOptions["rmdir"] = (
backend
) => {
return async (path, cb) => {
console.log("rmdir(%s)", path);
console.info("rmdir(%s)", path);
const r = await backend.deleteFile(path);
match(r)
.with({ status: "ok" }, (r) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/setxattr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const setxattr: (backend: SQLiteBackend) => MountOptions["setxattr"] = (
backend
) => {
return async (path, name, buffer, length, offset, flags, cb) => {
console.log(
console.info(
"setxattr(%s, %s, %s, %d, %d, %d)",
path,
name,
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/statfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const statfs: (backend: SQLiteBackend) => MountOptions["statfs"] = (
backend
) => {
return (path, cb) => {
console.log("statfs(%s)", path);
console.info("statfs(%s)", path);
// TODO: fill actual values, these are just placeholders
cb(0, {
bsize: 1000000, // Block size
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/truncate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const truncate: (backend: SQLiteBackend) => MountOptions["truncate"] = (
backend
) => {
return async (path, size, cb) => {
console.log("truncate(%s, %d)", path, size);
console.info("truncate(%s, %d)", path, size);
const r = await backend.truncateFile(path, size);
await match(r)
.with({ status: "ok" }, async (r) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/unlink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const unlink: (backend: SQLiteBackend) => MountOptions["unlink"] = (
backend
) => {
return async (path, cb) => {
console.log("unlink(%s)", path);
console.info("unlink(%s)", path);
const r = await backend.deleteFile(path);
if (r.status === "ok") {
cb(0);
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/utimens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const utimens: (backend: SQLiteBackend) => MountOptions["utimens"] = (
backend
) => {
return async (path, atime, mtime, cb) => {
console.log("utimens(%s, %s, %s)", path, atime, mtime);
console.info("utimens(%s, %s, %s)", path, atime, mtime);
try {
await backend.updateTimes(path, atime, mtime);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion packages/fuse-client/syscalls/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const write: (backend: SQLiteBackend) => MountOptions["write"] = (
backend
) => {
return async (path, fd, buf, len, pos, cb) => {
console.log("write(%s, %d, %d, %d)", path, fd, len, pos);
console.info("write(%s, %d, %d, %d)", path, fd, len, pos);
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 });
Expand Down
3 changes: 3 additions & 0 deletions packages/sqlite-backend/WriteBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export class WriteBuffer<T> {
async write(item: T): Promise<void> {
this.buffer.push(item);
if (this.buffer.length >= this.size) {
console.info(
`WriteBuffer.write: Flushing because buffer size exceeded the set limit of ${this.size}`
);
await this.flush();
}
// TODO: implement a time based flush, like, if there are no writes for 100ms
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- CreateTable
DROP TABLE IF EXISTS "File";
CREATE TABLE "File" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"type" TEXT NOT NULL,
Expand All @@ -7,14 +8,24 @@ CREATE TABLE "File" (
"name" TEXT NOT NULL,
"dir" TEXT NOT NULL,
"path" TEXT NOT NULL,
"content" BLOB NOT NULL,
"uid" INTEGER NOT NULL,
"gid" INTEGER NOT NULL,
"atime" DATETIME NOT NULL,
"mtime" DATETIME NOT NULL,
"ctime" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

DROP TABLE IF EXISTS "Content";
-- CreateTable
CREATE TABLE "Content" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"content" BLOB NOT NULL,
"offset" INTEGER NOT NULL,
"size" INTEGER NOT NULL,
"fileId" INTEGER NOT NULL,
CONSTRAINT "Content_fileId_fkey" FOREIGN KEY ("fileId") REFERENCES "File" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

-- CreateIndex
CREATE UNIQUE INDEX "File_path_key" ON "File"("path");

2 changes: 1 addition & 1 deletion packages/zoid-fs-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const backend = await match(backendArg)

const fuseClient = new FuseClient(backend);
setTimeout(async () => {
console.log("mounting: fuse mount points");
console.info("mounting: fuse mount points");
fuseClient.mountFS(mountPathArg);
}, 1000);

Expand Down

0 comments on commit 3f7c0d4

Please sign in to comment.