-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: link, symlinks with current database schema
- Loading branch information
Showing
11 changed files
with
168 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
import { SQLiteBackend } from "@zoid-fs/sqlite-backend"; | ||
import { MountOptions } from "@zoid-fs/node-fuse-bindings"; | ||
import { symlink } from "./symlink"; | ||
import fuse, { MountOptions } from "@zoid-fs/node-fuse-bindings"; | ||
import { match } from "ts-pattern"; | ||
|
||
export const link: (backend: SQLiteBackend) => MountOptions["link"] = ( | ||
backend | ||
) => { | ||
return async (src, dest, cb) => { | ||
console.log("link(%s, %s)", src, dest); | ||
return async (srcPath, destPath, cb) => { | ||
console.info("link(%s, %s)", srcPath, destPath); | ||
|
||
// TODO: throw if destination doesn't exist | ||
|
||
//@ts-expect-error fix types | ||
// TODO: implement link properly | ||
symlink(backend)(src, dest, cb); | ||
const context = fuse.context(); | ||
const { uid, gid } = context; | ||
|
||
// TODO: double check if mode for link is correct | ||
// https://unix.stackexchange.com/questions/193465/what-file-mode-is-a-link | ||
const r = await backend.createFile( | ||
destPath, | ||
"link", | ||
41453, // Link's mode??? from node-fuse-binding source, why though? | ||
uid, | ||
gid, | ||
srcPath | ||
); | ||
console.log({ r }); | ||
match(r) | ||
.with({ status: "ok" }, () => { | ||
cb(0); | ||
}) | ||
.with({ status: "not_found" }, () => { | ||
cb(fuse.ENOENT); | ||
}) | ||
.exhaustive(); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.