fix: only proceed if permission verified

This commit is contained in:
Yukun Guo
2020-12-11 11:09:56 +08:00
committed by Tienson Qin
parent 0b0598cee2
commit 92e791ecad
3 changed files with 14 additions and 15 deletions

View File

@@ -116,16 +116,16 @@ export var verifyPermission = async function (handle, readWrite) {
if (readWrite) {
options.mode = 'readwrite';
}
// Check if permission was already granted. If so, return true.
// Check if permission was already granted.
if ((await handle.queryPermission(options)) === 'granted') {
return true;
return;
}
// Request permission. If the user grants permission, return true.
// Request permission. If the user grants permission, just return.
if ((await handle.requestPermission(options)) === 'granted') {
return true;
return;
}
// The user didn't grant permission, so return false.
return false;
// The user didn't grant permission, throw an error.
throw new Error("Permission is not granted");
}
export var openDirectory = async function (options = {}, cb) {