-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: changing permission verify strategy #1374
base: main
Are you sure you want to change the base?
Changes from 2 commits
31feb4a
1cfe3dc
1f42ebd
71decd9
99364df
0adcc73
74d4975
9bb89a1
47f7731
715c4a6
92e641e
097aff1
f682c56
fb66557
40552cb
540fd80
5ac0c04
1d8a3c4
1b4f962
abf9d9b
3f8a440
33e1de7
16a3b1e
8ef2377
e4fefde
8f1acb4
5889f62
04db9a7
64b10a0
ce223a4
6698d2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
|
||
import { registerEvent } from "../register-event"; | ||
|
||
const checkFolderWritePermission = async ( | ||
_event: Electron.IpcMainInvokeEvent, | ||
path: string | ||
) => | ||
new Promise((resolve) => { | ||
fs.access(path, fs.constants.W_OK, (err) => { | ||
resolve(!err); | ||
}); | ||
}); | ||
testPath: string | ||
) => { | ||
const testFilePath = path.join(testPath, ".hydra-write-test"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: consider using a more unique filename with timestamp/uuid to avoid potential conflicts |
||
|
||
try { | ||
fs.writeFileSync(testFilePath, ""); | ||
fs.rmSync(testFilePath); | ||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: using synchronous fs operations can block the main thread - consider using async writeFile/rm |
||
return true; | ||
} catch (err) { | ||
return false; | ||
} | ||
Comment on lines
+16
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: error is silently swallowed - should at least log it for debugging purposes |
||
}; | ||
|
||
registerEvent("checkFolderWritePermission", checkFolderWritePermission); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: function is marked async but contains no await operations - should either use async fs operations or remove async keyword