@cloudbase/manager-node 4.4.4 → 4.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/utils/fs.js +13 -6
- package/package.json +1 -1
package/lib/utils/fs.js
CHANGED
|
@@ -14,20 +14,27 @@ const del_1 = __importDefault(require("del"));
|
|
|
14
14
|
// 检查路径是否可以访问(读、写)
|
|
15
15
|
function checkFullAccess(dest, throwError = false) {
|
|
16
16
|
try {
|
|
17
|
-
//
|
|
17
|
+
// 检查路径是否存在
|
|
18
18
|
fs_1.default.accessSync(dest, fs_1.default.constants.F_OK);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
if (throwError) {
|
|
22
|
+
throw new error_1.CloudBaseError(`路径不存在:${dest}`);
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
19
27
|
fs_1.default.accessSync(dest, fs_1.default.constants.W_OK);
|
|
20
28
|
fs_1.default.accessSync(dest, fs_1.default.constants.R_OK);
|
|
21
|
-
return true;
|
|
22
29
|
}
|
|
23
30
|
catch (e) {
|
|
24
31
|
if (throwError) {
|
|
25
|
-
throw new error_1.CloudBaseError(
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
return false;
|
|
32
|
+
throw new error_1.CloudBaseError(`路径无读写权限:${dest}`);
|
|
29
33
|
}
|
|
34
|
+
return false;
|
|
30
35
|
}
|
|
36
|
+
// 所有检查都通过
|
|
37
|
+
return true;
|
|
31
38
|
}
|
|
32
39
|
// 检查路径是否可以写
|
|
33
40
|
function checkReadable(dest, throwError = false) {
|