Skip to content

Commit

Permalink
Throw permission error if the at flag is specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
saul-jb committed Feb 27, 2024
1 parent db9384a commit af626d2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/fuse/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ const opts: FuseOpts = {
},

async write (path, _, buffer, length, position) {
if (argv.at !== null) {
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw Fuse.EACCES
}

const written = await client.write(argv.group, path, uint8ArrayToString(buffer), {
position,
length
Expand All @@ -216,6 +221,11 @@ const opts: FuseOpts = {
},

async create (path) {
if (argv.at !== null) {
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw Fuse.EACCES
}

await client.write(argv.group, path, uint8ArrayToString(new Uint8Array([])), {
length: 0
})
Expand All @@ -224,10 +234,20 @@ const opts: FuseOpts = {
},

async unlink (path: string) {
if (argv.at !== null) {
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw Fuse.EACCES
}

await client.delete(argv.group, path)
},

async rename (src, dest) {
if (argv.at !== null) {
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw Fuse.EACCES
}

const list = await group.query()
const files = list.filter((l: { path: string }) => l.path.startsWith(Path.join(src, '/')) || l.path === src)

Expand All @@ -254,6 +274,11 @@ const opts: FuseOpts = {
},

async mkdir (path) {
if (argv.at !== null) {
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw Fuse.EACCES
}

await client.write(
argv.group,
Path.join(path, '.PLACE_HOLDER'),
Expand All @@ -265,6 +290,11 @@ const opts: FuseOpts = {
},

async rmdir (path) {
if (argv.at !== null) {
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw Fuse.EACCES
}

const list = await group.query()
const files = list.filter((l: { path: string }) => l.path.startsWith(Path.join(path, '/')))

Expand Down

0 comments on commit af626d2

Please sign in to comment.