clickgo 3.1.4-dev13 → 3.1.6-dev15
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/README.md +7 -7
- package/dist/app/demo/app.js +29 -3
- package/dist/app/demo/config.json +22 -3
- package/dist/app/demo/form/control/box/box.js +66 -0
- package/dist/app/demo/form/control/box/box.xml +18 -0
- package/dist/app/demo/form/control/button/button.js +24 -1
- package/dist/app/demo/form/control/check/check.js +24 -1
- package/dist/app/demo/form/control/dialog/dialog.js +24 -1
- package/dist/app/demo/form/control/file/file.js +24 -1
- package/dist/app/demo/form/control/flow/flow.js +24 -1
- package/dist/app/demo/form/control/form/form.js +24 -1
- package/dist/app/demo/form/control/layout/layout.js +57 -0
- package/dist/app/demo/form/control/layout/layout.xml +16 -0
- package/dist/app/demo/form/control/list/list.js +24 -1
- package/dist/app/demo/form/control/list/list.xml +8 -2
- package/dist/app/demo/form/control/marquee/marquee.js +24 -2
- package/dist/app/demo/form/control/marquee/marquee.xml +2 -5
- package/dist/app/demo/form/control/menu/menu.js +24 -1
- package/dist/app/demo/form/control/monaco/monaco.js +24 -1
- package/dist/app/demo/form/control/nav/nav.js +52 -0
- package/dist/app/demo/form/control/nav/nav.xml +43 -0
- package/dist/app/demo/form/control/panel/panel.js +67 -0
- package/dist/app/demo/form/control/panel/panel.xml +11 -0
- package/dist/app/demo/form/control/panel/test1.js +58 -0
- package/dist/app/demo/form/control/panel/test1.xml +16 -0
- package/dist/app/demo/form/control/panel/test2.xml +3 -0
- package/dist/app/demo/form/control/property/property.js +24 -1
- package/dist/app/demo/form/control/radio/radio.js +24 -1
- package/dist/app/demo/form/control/scroll/scroll.js +25 -1
- package/dist/app/demo/form/control/scroll/scroll.xml +5 -2
- package/dist/app/demo/form/control/select/select.js +24 -1
- package/dist/app/demo/form/control/tab/tab.js +24 -1
- package/dist/app/demo/form/control/table/table.js +164 -0
- package/dist/app/demo/form/control/table/table.xml +35 -0
- package/dist/app/demo/form/control/text/text.js +25 -1
- package/dist/app/demo/form/control/text/text.xml +1 -1
- package/dist/app/demo/form/control/vflow/vflow.js +24 -1
- package/dist/app/demo/form/event/form/form.js +24 -1
- package/dist/app/demo/form/event/other/other.js +24 -1
- package/dist/app/demo/form/event/screen/screen.js +24 -1
- package/dist/app/demo/form/event/task/task.js +24 -1
- package/dist/app/demo/form/main.js +130 -84
- package/dist/app/demo/form/main.xml +5 -0
- package/dist/app/demo/form/method/aform/aform.js +29 -15
- package/dist/app/demo/form/method/aform/aform.xml +0 -1
- package/dist/app/demo/form/method/aform/sd.js +25 -5
- package/dist/app/demo/form/method/core/core.js +24 -1
- package/dist/app/demo/form/method/dom/dom.js +48 -2
- package/dist/app/demo/form/method/dom/dom.xml +11 -0
- package/dist/app/demo/form/method/form/form.js +40 -7
- package/dist/app/demo/form/method/form/form.xml +3 -0
- package/dist/app/demo/form/method/{aform → form}/test.xml +0 -0
- package/dist/app/demo/form/method/fs/fs.js +139 -8
- package/dist/app/demo/form/method/fs/fs.xml +11 -1
- package/dist/app/demo/form/method/fs/text.js +24 -1
- package/dist/app/demo/form/method/native/native.js +24 -1
- package/dist/app/demo/form/method/system/system.js +24 -1
- package/dist/app/demo/form/method/task/task.js +31 -4
- package/dist/app/demo/form/method/task/task.xml +6 -1
- package/dist/app/demo/form/method/theme/theme.js +24 -1
- package/dist/app/demo/form/method/tool/tool.js +38 -1
- package/dist/app/demo/form/method/tool/tool.xml +1 -0
- package/dist/app/demo/form/method/zip/zip.js +30 -7
- package/dist/app/task/app.js +29 -3
- package/dist/app/task/form/bar/bar.js +24 -1
- package/dist/clickgo.js +33 -10
- package/dist/control/box.cgc +0 -0
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/nav.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/table.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -1
- package/dist/lib/control.js +53 -12
- package/dist/lib/control.ts +25 -5
- package/dist/lib/core.js +44 -50
- package/dist/lib/core.ts +18 -48
- package/dist/lib/dom.js +322 -108
- package/dist/lib/dom.ts +394 -127
- package/dist/lib/form.js +590 -226
- package/dist/lib/form.ts +706 -267
- package/dist/lib/fs.js +485 -224
- package/dist/lib/fs.ts +493 -287
- package/dist/lib/native.js +24 -1
- package/dist/lib/task.js +159 -139
- package/dist/lib/task.ts +148 -130
- package/dist/lib/theme.js +27 -4
- package/dist/lib/tool.js +57 -2
- package/dist/lib/tool.ts +68 -1
- package/dist/lib/zip.js +29 -3
- package/dist/lib/zip.ts +1 -1
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +5 -7
- package/types/index.d.ts +51 -70
package/dist/lib/fs.js
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,23 +33,40 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
33
|
};
|
|
11
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
35
|
exports.copyFile = exports.copyFolder = exports.readDir = exports.rename = exports.chmod = exports.rmdirDeep = exports.rmdir = exports.mkdir = exports.isFile = exports.isDir = exports.stats = exports.unlink = exports.symlink = exports.readLink = exports.putContent = exports.getContent = exports.unmount = exports.mount = void 0;
|
|
13
|
-
const tool = require("./tool");
|
|
14
|
-
const task = require("./task");
|
|
15
|
-
const
|
|
36
|
+
const tool = __importStar(require("./tool"));
|
|
37
|
+
const task = __importStar(require("./task"));
|
|
38
|
+
const form = __importStar(require("./form"));
|
|
39
|
+
const core = __importStar(require("./core"));
|
|
40
|
+
const native = __importStar(require("./native"));
|
|
41
|
+
const clickgoFiles = ['/app/', '/app/demo/', '/app/demo/app.js', '/app/demo/config.json', '/app/demo/form/', '/app/demo/form/control/', '/app/demo/form/control/block/', '/app/demo/form/control/block/block.css', '/app/demo/form/control/block/block.xml', '/app/demo/form/control/box/', '/app/demo/form/control/box/box.js', '/app/demo/form/control/box/box.xml', '/app/demo/form/control/button/', '/app/demo/form/control/button/button.css', '/app/demo/form/control/button/button.js', '/app/demo/form/control/button/button.xml', '/app/demo/form/control/check/', '/app/demo/form/control/check/check.js', '/app/demo/form/control/check/check.xml', '/app/demo/form/control/dialog/', '/app/demo/form/control/dialog/dialog.js', '/app/demo/form/control/dialog/dialog.xml', '/app/demo/form/control/file/', '/app/demo/form/control/file/file.js', '/app/demo/form/control/file/file.xml', '/app/demo/form/control/flow/', '/app/demo/form/control/flow/flow.css', '/app/demo/form/control/flow/flow.js', '/app/demo/form/control/flow/flow.xml', '/app/demo/form/control/form/', '/app/demo/form/control/form/form.css', '/app/demo/form/control/form/form.js', '/app/demo/form/control/form/form.xml', '/app/demo/form/control/img/', '/app/demo/form/control/img/img.xml', '/app/demo/form/control/label/', '/app/demo/form/control/label/label.xml', '/app/demo/form/control/layout/', '/app/demo/form/control/layout/layout.js', '/app/demo/form/control/layout/layout.xml', '/app/demo/form/control/list/', '/app/demo/form/control/list/list.css', '/app/demo/form/control/list/list.js', '/app/demo/form/control/list/list.xml', '/app/demo/form/control/loading/', '/app/demo/form/control/loading/loading.xml', '/app/demo/form/control/marquee/', '/app/demo/form/control/marquee/marquee.js', '/app/demo/form/control/marquee/marquee.xml', '/app/demo/form/control/menu/', '/app/demo/form/control/menu/menu.js', '/app/demo/form/control/menu/menu.xml', '/app/demo/form/control/monaco/', '/app/demo/form/control/monaco/monaco.js', '/app/demo/form/control/monaco/monaco.xml', '/app/demo/form/control/nav/', '/app/demo/form/control/nav/nav.js', '/app/demo/form/control/nav/nav.xml', '/app/demo/form/control/panel/', '/app/demo/form/control/panel/panel.js', '/app/demo/form/control/panel/panel.xml', '/app/demo/form/control/panel/test1.js', '/app/demo/form/control/panel/test1.xml', '/app/demo/form/control/panel/test2.xml', '/app/demo/form/control/property/', '/app/demo/form/control/property/property.js', '/app/demo/form/control/property/property.xml', '/app/demo/form/control/radio/', '/app/demo/form/control/radio/radio.js', '/app/demo/form/control/radio/radio.xml', '/app/demo/form/control/scroll/', '/app/demo/form/control/scroll/scroll.js', '/app/demo/form/control/scroll/scroll.xml', '/app/demo/form/control/select/', '/app/demo/form/control/select/select.js', '/app/demo/form/control/select/select.xml', '/app/demo/form/control/tab/', '/app/demo/form/control/tab/tab.js', '/app/demo/form/control/tab/tab.xml', '/app/demo/form/control/table/', '/app/demo/form/control/table/table.js', '/app/demo/form/control/table/table.xml', '/app/demo/form/control/text/', '/app/demo/form/control/text/text.js', '/app/demo/form/control/text/text.xml', '/app/demo/form/control/vflow/', '/app/demo/form/control/vflow/vflow.css', '/app/demo/form/control/vflow/vflow.js', '/app/demo/form/control/vflow/vflow.xml', '/app/demo/form/event/', '/app/demo/form/event/form/', '/app/demo/form/event/form/form.css', '/app/demo/form/event/form/form.js', '/app/demo/form/event/form/form.xml', '/app/demo/form/event/other/', '/app/demo/form/event/other/other.js', '/app/demo/form/event/other/other.xml', '/app/demo/form/event/screen/', '/app/demo/form/event/screen/screen.js', '/app/demo/form/event/screen/screen.xml', '/app/demo/form/event/task/', '/app/demo/form/event/task/task.js', '/app/demo/form/event/task/task.xml', '/app/demo/form/main.css', '/app/demo/form/main.js', '/app/demo/form/main.xml', '/app/demo/form/method/', '/app/demo/form/method/aform/', '/app/demo/form/method/aform/aform.js', '/app/demo/form/method/aform/aform.xml', '/app/demo/form/method/aform/sd.js', '/app/demo/form/method/aform/sd.xml', '/app/demo/form/method/core/', '/app/demo/form/method/core/core.js', '/app/demo/form/method/core/core.xml', '/app/demo/form/method/dom/', '/app/demo/form/method/dom/dom.css', '/app/demo/form/method/dom/dom.js', '/app/demo/form/method/dom/dom.xml', '/app/demo/form/method/form/', '/app/demo/form/method/form/form.css', '/app/demo/form/method/form/form.js', '/app/demo/form/method/form/form.xml', '/app/demo/form/method/form/test.xml', '/app/demo/form/method/fs/', '/app/demo/form/method/fs/fs.js', '/app/demo/form/method/fs/fs.xml', '/app/demo/form/method/fs/text.js', '/app/demo/form/method/fs/text.xml', '/app/demo/form/method/native/', '/app/demo/form/method/native/native.js', '/app/demo/form/method/native/native.xml', '/app/demo/form/method/system/', '/app/demo/form/method/system/system.js', '/app/demo/form/method/system/system.xml', '/app/demo/form/method/task/', '/app/demo/form/method/task/locale1.json', '/app/demo/form/method/task/locale2.json', '/app/demo/form/method/task/task.js', '/app/demo/form/method/task/task.xml', '/app/demo/form/method/theme/', '/app/demo/form/method/theme/theme.js', '/app/demo/form/method/theme/theme.xml', '/app/demo/form/method/tool/', '/app/demo/form/method/tool/tool.js', '/app/demo/form/method/tool/tool.xml', '/app/demo/form/method/zip/', '/app/demo/form/method/zip/zip.js', '/app/demo/form/method/zip/zip.xml', '/app/demo/global.css', '/app/demo/res/', '/app/demo/res/icon.svg', '/app/demo/res/img.jpg', '/app/demo/res/r-1.svg', '/app/demo/res/r-2.svg', '/app/demo/res/sql.svg', '/app/demo/res/txt.svg', '/app/demo/res/zip.svg', '/app/task/', '/app/task/app.js', '/app/task/config.json', '/app/task/form/', '/app/task/form/bar/', '/app/task/form/bar/bar.js', '/app/task/form/bar/bar.xml', '/app/task/form/desktop/', '/app/task/form/desktop/desktop.xml', '/app/task/locale/', '/app/task/locale/en.json', '/app/task/locale/ja.json', '/app/task/locale/sc.json', '/app/task/locale/tc.json', '/clickgo.js', '/clickgo.ts', '/control/', '/control/box.cgc', '/control/common.cgc', '/control/form.cgc', '/control/monaco.cgc', '/control/nav.cgc', '/control/property.cgc', '/control/table.cgc', '/control/task.cgc', '/global.css', '/icon.png', '/index.js', '/index.ts', '/lib/', '/lib/control.js', '/lib/control.ts', '/lib/core.js', '/lib/core.ts', '/lib/dom.js', '/lib/dom.ts', '/lib/form.js', '/lib/form.ts', '/lib/fs.js', '/lib/fs.ts', '/lib/native.js', '/lib/native.ts', '/lib/task.js', '/lib/task.ts', '/lib/theme.js', '/lib/theme.ts', '/lib/tool.js', '/lib/tool.ts', '/lib/zip.js', '/lib/zip.ts', '/theme/', '/theme/familiar.cgt'];
|
|
42
|
+
const localeData = {
|
|
43
|
+
'en': {
|
|
44
|
+
'apply-unmount': 'Are you sure to unmount the "?" mount point?',
|
|
45
|
+
},
|
|
46
|
+
'sc': {
|
|
47
|
+
'apply-unmount': '确定卸载“?”挂载点吗?'
|
|
48
|
+
},
|
|
49
|
+
'tc': {
|
|
50
|
+
'apply-unmount': '確定卸載「?」掛載點嗎?'
|
|
51
|
+
},
|
|
52
|
+
'ja': {
|
|
53
|
+
'apply-unmount': '「?」マウント ポイントをアンマウントしますか?'
|
|
54
|
+
}
|
|
55
|
+
};
|
|
16
56
|
const mounts = {};
|
|
17
57
|
function getMountName(path) {
|
|
18
58
|
const io = path.slice(9).indexOf('/');
|
|
19
|
-
return path.slice(9, io + 9);
|
|
59
|
+
return io === -1 ? path.slice(9) : path.slice(9, io + 9);
|
|
20
60
|
}
|
|
21
|
-
function mount(name, handler) {
|
|
61
|
+
function mount(name, handler, taskId) {
|
|
22
62
|
if (mounts[name]) {
|
|
23
63
|
return false;
|
|
24
64
|
}
|
|
25
65
|
if (!/^[a-zA-Z][\w]+$/.test(name)) {
|
|
26
66
|
return false;
|
|
27
67
|
}
|
|
28
|
-
if (
|
|
29
|
-
const t = task.list[
|
|
68
|
+
if (taskId) {
|
|
69
|
+
const t = task.list[taskId];
|
|
30
70
|
if (t) {
|
|
31
71
|
const val = 'fs./mounted/' + name + '/w';
|
|
32
72
|
if (!t.runtime.permissions.includes(val)) {
|
|
@@ -34,22 +74,27 @@ function mount(name, handler) {
|
|
|
34
74
|
}
|
|
35
75
|
}
|
|
36
76
|
}
|
|
77
|
+
handler.date = new Date();
|
|
37
78
|
mounts[name] = handler;
|
|
38
79
|
return true;
|
|
39
80
|
}
|
|
40
81
|
exports.mount = mount;
|
|
41
|
-
function unmount(name
|
|
42
|
-
|
|
82
|
+
function unmount(name) {
|
|
83
|
+
var _a, _b;
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (!mounts[name]) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
const loc = (_b = (_a = localeData[core.config.locale]) === null || _a === void 0 ? void 0 : _a['apply-unmount']) !== null && _b !== void 0 ? _b : localeData['en']['apply-unmount'];
|
|
89
|
+
if (!(yield form.superConfirm(loc.replace('?', '/mount/' + name + '/')))) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
delete mounts[name];
|
|
43
93
|
return true;
|
|
44
|
-
}
|
|
45
|
-
if (taskId && (mounts[name].taskId !== taskId)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
delete mounts[name];
|
|
49
|
-
return true;
|
|
94
|
+
});
|
|
50
95
|
}
|
|
51
96
|
exports.unmount = unmount;
|
|
52
|
-
function getContent(path, options) {
|
|
97
|
+
function getContent(path, options, taskId) {
|
|
53
98
|
var _a, _b;
|
|
54
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
100
|
path = tool.urlResolve('/', path);
|
|
@@ -113,22 +158,41 @@ function getContent(path, options) {
|
|
|
113
158
|
return null;
|
|
114
159
|
}
|
|
115
160
|
}
|
|
116
|
-
else if (path.startsWith('/storage/')) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
161
|
+
else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
|
|
162
|
+
const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
|
|
163
|
+
if (!r[0]) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
if (path.startsWith('/mounted/')) {
|
|
167
|
+
const name = getMountName(path);
|
|
168
|
+
const hanlder = mounts[name];
|
|
169
|
+
if (!hanlder) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return (_b = (_a = hanlder.getContent) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), options)) !== null && _b !== void 0 ? _b : null;
|
|
173
|
+
}
|
|
174
|
+
if (options.progress) {
|
|
175
|
+
delete options.progress;
|
|
176
|
+
}
|
|
177
|
+
const rtn = yield native.invoke('cg-fs-getContent', native.getToken(), fpath, options);
|
|
178
|
+
if (!rtn) {
|
|
123
179
|
return null;
|
|
124
180
|
}
|
|
125
|
-
|
|
181
|
+
if (typeof rtn === 'string') {
|
|
182
|
+
return rtn;
|
|
183
|
+
}
|
|
184
|
+
return new Blob([rtn], {
|
|
185
|
+
'type': tool.getMimeByPath(path).mime
|
|
186
|
+
});
|
|
126
187
|
}
|
|
127
|
-
else if (path.startsWith('/package/')) {
|
|
128
|
-
if (!
|
|
188
|
+
else if (path.startsWith('/package/') || path.startsWith('/current/')) {
|
|
189
|
+
if (!taskId) {
|
|
129
190
|
return null;
|
|
130
191
|
}
|
|
131
|
-
|
|
192
|
+
if (path.startsWith('/current/')) {
|
|
193
|
+
return getContent(task.list[taskId].current + fpath, options, taskId);
|
|
194
|
+
}
|
|
195
|
+
const file = task.list[taskId].app.files[fpath];
|
|
132
196
|
if (!file) {
|
|
133
197
|
return null;
|
|
134
198
|
}
|
|
@@ -136,7 +200,10 @@ function getContent(path, options) {
|
|
|
136
200
|
return file;
|
|
137
201
|
}
|
|
138
202
|
if (!options.encoding) {
|
|
139
|
-
|
|
203
|
+
if (start === undefined && end === undefined) {
|
|
204
|
+
return file;
|
|
205
|
+
}
|
|
206
|
+
return file.slice(start, end, file.type);
|
|
140
207
|
}
|
|
141
208
|
const encoding = options.encoding;
|
|
142
209
|
return new Promise(function (resolve) {
|
|
@@ -147,20 +214,13 @@ function getContent(path, options) {
|
|
|
147
214
|
fr.readAsText(file, encoding);
|
|
148
215
|
});
|
|
149
216
|
}
|
|
150
|
-
else if (path.startsWith('/current/')) {
|
|
151
|
-
if (!options.current) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
|
|
155
|
-
return getContent(current + fpath, options);
|
|
156
|
-
}
|
|
157
217
|
else {
|
|
158
218
|
return null;
|
|
159
219
|
}
|
|
160
220
|
});
|
|
161
221
|
}
|
|
162
222
|
exports.getContent = getContent;
|
|
163
|
-
function putContent(path, data, options = {}) {
|
|
223
|
+
function putContent(path, data, options = {}, taskId) {
|
|
164
224
|
var _a, _b;
|
|
165
225
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
226
|
path = tool.urlResolve('/', path);
|
|
@@ -168,26 +228,33 @@ function putContent(path, data, options = {}) {
|
|
|
168
228
|
if (path.startsWith('/clickgo/')) {
|
|
169
229
|
return false;
|
|
170
230
|
}
|
|
171
|
-
else if (path.startsWith('/storage/')) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
else if (path.startsWith('/mounted/')) {
|
|
175
|
-
const name = getMountName(path);
|
|
176
|
-
const hanlder = mounts[name];
|
|
177
|
-
if (!hanlder) {
|
|
231
|
+
else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
|
|
232
|
+
const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
|
|
233
|
+
if (!r[0]) {
|
|
178
234
|
return false;
|
|
179
235
|
}
|
|
180
|
-
|
|
236
|
+
if (path.startsWith('/mounted/')) {
|
|
237
|
+
const name = getMountName(path);
|
|
238
|
+
const hanlder = mounts[name];
|
|
239
|
+
if (!hanlder) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
return (_b = (_a = hanlder.putContent) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), data, options)) !== null && _b !== void 0 ? _b : false;
|
|
243
|
+
}
|
|
244
|
+
let buf = undefined;
|
|
245
|
+
if (data instanceof Blob) {
|
|
246
|
+
buf = new Uint8Array(yield data.arrayBuffer());
|
|
247
|
+
}
|
|
248
|
+
return native.invoke('cg-fs-putContent', native.getToken(), fpath, buf !== null && buf !== void 0 ? buf : data, options);
|
|
181
249
|
}
|
|
182
250
|
else if (path.startsWith('/package/')) {
|
|
183
251
|
return false;
|
|
184
252
|
}
|
|
185
253
|
else if (path.startsWith('/current/')) {
|
|
186
|
-
if (!
|
|
254
|
+
if (!taskId) {
|
|
187
255
|
return false;
|
|
188
256
|
}
|
|
189
|
-
|
|
190
|
-
return putContent(current + fpath, data, options);
|
|
257
|
+
return putContent(task.list[taskId].current + fpath, data, options, taskId);
|
|
191
258
|
}
|
|
192
259
|
else {
|
|
193
260
|
return false;
|
|
@@ -195,44 +262,37 @@ function putContent(path, data, options = {}) {
|
|
|
195
262
|
});
|
|
196
263
|
}
|
|
197
264
|
exports.putContent = putContent;
|
|
198
|
-
function readLink(path,
|
|
265
|
+
function readLink(path, encoding, taskId) {
|
|
199
266
|
var _a, _b;
|
|
200
267
|
return __awaiter(this, void 0, void 0, function* () {
|
|
201
268
|
path = tool.urlResolve('/', path);
|
|
202
269
|
const fpath = path.slice(8);
|
|
203
|
-
if (typeof options === 'string') {
|
|
204
|
-
options = {
|
|
205
|
-
'encoding': options
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
else if (!options) {
|
|
209
|
-
options = {};
|
|
210
|
-
}
|
|
211
270
|
if (path.startsWith('/clickgo/')) {
|
|
212
271
|
return null;
|
|
213
272
|
}
|
|
214
|
-
else if (path.startsWith('/storage/')) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
else if (path.startsWith('/mounted/')) {
|
|
218
|
-
const name = getMountName(path);
|
|
219
|
-
const hanlder = mounts[name];
|
|
220
|
-
if (!hanlder) {
|
|
273
|
+
else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
|
|
274
|
+
const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
|
|
275
|
+
if (!r[0]) {
|
|
221
276
|
return null;
|
|
222
277
|
}
|
|
223
|
-
|
|
278
|
+
if (path.startsWith('/mounted/')) {
|
|
279
|
+
const name = getMountName(path);
|
|
280
|
+
const hanlder = mounts[name];
|
|
281
|
+
if (!hanlder) {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
return (_b = (_a = hanlder.readLink) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), encoding)) !== null && _b !== void 0 ? _b : null;
|
|
285
|
+
}
|
|
286
|
+
return native.invoke('cg-fs-readLink', native.getToken(), fpath, encoding);
|
|
224
287
|
}
|
|
225
288
|
else if (path.startsWith('/package/')) {
|
|
226
289
|
return null;
|
|
227
290
|
}
|
|
228
291
|
else if (path.startsWith('/current/')) {
|
|
229
|
-
if (!
|
|
292
|
+
if (!taskId) {
|
|
230
293
|
return null;
|
|
231
294
|
}
|
|
232
|
-
|
|
233
|
-
return options.current.slice(0, -1);
|
|
234
|
-
}
|
|
235
|
-
return options.current;
|
|
295
|
+
return task.list[taskId].current;
|
|
236
296
|
}
|
|
237
297
|
else {
|
|
238
298
|
return null;
|
|
@@ -240,7 +300,7 @@ function readLink(path, options) {
|
|
|
240
300
|
});
|
|
241
301
|
}
|
|
242
302
|
exports.readLink = readLink;
|
|
243
|
-
function symlink(filePath, linkPath,
|
|
303
|
+
function symlink(filePath, linkPath, type, taskId) {
|
|
244
304
|
var _a, _b;
|
|
245
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
246
306
|
filePath = tool.urlResolve('/', filePath);
|
|
@@ -248,33 +308,36 @@ function symlink(filePath, linkPath, options = {}) {
|
|
|
248
308
|
if (filePath.startsWith('/clickgo/')) {
|
|
249
309
|
return false;
|
|
250
310
|
}
|
|
251
|
-
else if (filePath.startsWith('/storage/')) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
else if (filePath.startsWith('/mounted/')) {
|
|
255
|
-
const fname = getMountName(filePath);
|
|
256
|
-
const lname = getMountName(linkPath);
|
|
257
|
-
if (fname !== lname) {
|
|
311
|
+
else if (filePath.startsWith('/storage/') || filePath.startsWith('/mounted/')) {
|
|
312
|
+
const r = yield task.checkPermission('fs.' + filePath + 'w', false, undefined, taskId);
|
|
313
|
+
if (!r[0]) {
|
|
258
314
|
return false;
|
|
259
315
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
316
|
+
if (filePath.startsWith('/mounted/')) {
|
|
317
|
+
const fname = getMountName(filePath);
|
|
318
|
+
const lname = getMountName(linkPath);
|
|
319
|
+
if (fname !== lname) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
const hanlder = mounts[fname];
|
|
323
|
+
if (!hanlder) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
return (_b = (_a = hanlder.symlink) === null || _a === void 0 ? void 0 : _a.call(hanlder, filePath.slice(9 + fname.length), linkPath.slice(9 + fname.length), type)) !== null && _b !== void 0 ? _b : false;
|
|
263
327
|
}
|
|
264
|
-
return (
|
|
328
|
+
return native.invoke('cg-fs-symlink', native.getToken(), filePath.slice(8), linkPath.slice(8), type);
|
|
265
329
|
}
|
|
266
330
|
else if (filePath.startsWith('/package/')) {
|
|
267
331
|
return false;
|
|
268
332
|
}
|
|
269
333
|
else if (filePath.startsWith('/current/')) {
|
|
270
|
-
if (!
|
|
334
|
+
if (!taskId) {
|
|
271
335
|
return false;
|
|
272
336
|
}
|
|
273
|
-
const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
|
|
274
337
|
if (linkPath.startsWith('/current/')) {
|
|
275
|
-
linkPath = current + linkPath.slice(8);
|
|
338
|
+
linkPath = task.list[taskId].current + linkPath.slice(8);
|
|
276
339
|
}
|
|
277
|
-
return symlink(current + filePath.slice(8), linkPath,
|
|
340
|
+
return symlink(task.list[taskId].current + filePath.slice(8), linkPath, type, taskId);
|
|
278
341
|
}
|
|
279
342
|
else {
|
|
280
343
|
return false;
|
|
@@ -282,7 +345,7 @@ function symlink(filePath, linkPath, options = {}) {
|
|
|
282
345
|
});
|
|
283
346
|
}
|
|
284
347
|
exports.symlink = symlink;
|
|
285
|
-
function unlink(path,
|
|
348
|
+
function unlink(path, taskId) {
|
|
286
349
|
var _a, _b;
|
|
287
350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
288
351
|
path = tool.urlResolve('/', path);
|
|
@@ -290,26 +353,29 @@ function unlink(path, options = {}) {
|
|
|
290
353
|
if (path.startsWith('/clickgo/')) {
|
|
291
354
|
return false;
|
|
292
355
|
}
|
|
293
|
-
else if (path.startsWith('/storage/')) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
else if (path.startsWith('/mounted/')) {
|
|
297
|
-
const name = getMountName(path);
|
|
298
|
-
const hanlder = mounts[name];
|
|
299
|
-
if (!hanlder) {
|
|
356
|
+
else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
|
|
357
|
+
const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
|
|
358
|
+
if (!r[0]) {
|
|
300
359
|
return false;
|
|
301
360
|
}
|
|
302
|
-
|
|
361
|
+
if (path.startsWith('/mounted/')) {
|
|
362
|
+
const name = getMountName(path);
|
|
363
|
+
const hanlder = mounts[name];
|
|
364
|
+
if (!hanlder) {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
return (_b = (_a = hanlder.unlink) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length))) !== null && _b !== void 0 ? _b : false;
|
|
368
|
+
}
|
|
369
|
+
return native.invoke('cg-fs-unlink', native.getToken(), fpath);
|
|
303
370
|
}
|
|
304
371
|
else if (path.startsWith('/package/')) {
|
|
305
372
|
return false;
|
|
306
373
|
}
|
|
307
374
|
else if (path.startsWith('/current/')) {
|
|
308
|
-
if (!
|
|
375
|
+
if (!taskId) {
|
|
309
376
|
return false;
|
|
310
377
|
}
|
|
311
|
-
|
|
312
|
-
return unlink(current + fpath, options);
|
|
378
|
+
return unlink(task.list[taskId].current + fpath, taskId);
|
|
313
379
|
}
|
|
314
380
|
else {
|
|
315
381
|
return false;
|
|
@@ -353,7 +419,11 @@ function getClickGoStats(path) {
|
|
|
353
419
|
});
|
|
354
420
|
const hdate = res.headers.get('date');
|
|
355
421
|
const hmdate = res.headers.get('last-modified');
|
|
356
|
-
|
|
422
|
+
let hlength = res.headers.get('content-range');
|
|
423
|
+
if (hlength) {
|
|
424
|
+
const lio = hlength.lastIndexOf('/');
|
|
425
|
+
hlength = hlength.slice(lio + 1);
|
|
426
|
+
}
|
|
357
427
|
let date = new Date();
|
|
358
428
|
let mdate = date;
|
|
359
429
|
if (hdate) {
|
|
@@ -392,10 +462,63 @@ function getClickGoStats(path) {
|
|
|
392
462
|
}
|
|
393
463
|
});
|
|
394
464
|
}
|
|
395
|
-
function stats(path,
|
|
465
|
+
function stats(path, taskId) {
|
|
396
466
|
var _a, _b;
|
|
397
467
|
return __awaiter(this, void 0, void 0, function* () {
|
|
398
468
|
path = tool.urlResolve('/', path);
|
|
469
|
+
if (path.endsWith('/')) {
|
|
470
|
+
path = path.slice(0, -1);
|
|
471
|
+
}
|
|
472
|
+
if (['', '/clickgo', '/storage', '/mounted', '/package'].includes(path)) {
|
|
473
|
+
const date = new Date();
|
|
474
|
+
const ms = date.getTime();
|
|
475
|
+
return {
|
|
476
|
+
isFile: function () {
|
|
477
|
+
return false;
|
|
478
|
+
},
|
|
479
|
+
isDirectory: function () {
|
|
480
|
+
return true;
|
|
481
|
+
},
|
|
482
|
+
isSymbolicLink: function () {
|
|
483
|
+
return false;
|
|
484
|
+
},
|
|
485
|
+
'size': 0,
|
|
486
|
+
'blksize': 0,
|
|
487
|
+
'atimeMs': ms,
|
|
488
|
+
'mtimeMs': ms,
|
|
489
|
+
'ctimeMs': ms,
|
|
490
|
+
'birthtimeMs': ms,
|
|
491
|
+
'atime': date,
|
|
492
|
+
'mtime': date,
|
|
493
|
+
'ctime': date,
|
|
494
|
+
'birthtime': date
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
if (path === '/current') {
|
|
498
|
+
const date = new Date();
|
|
499
|
+
const ms = date.getTime();
|
|
500
|
+
return {
|
|
501
|
+
isFile: function () {
|
|
502
|
+
return false;
|
|
503
|
+
},
|
|
504
|
+
isDirectory: function () {
|
|
505
|
+
return false;
|
|
506
|
+
},
|
|
507
|
+
isSymbolicLink: function () {
|
|
508
|
+
return true;
|
|
509
|
+
},
|
|
510
|
+
'size': 0,
|
|
511
|
+
'blksize': 0,
|
|
512
|
+
'atimeMs': ms,
|
|
513
|
+
'mtimeMs': ms,
|
|
514
|
+
'ctimeMs': ms,
|
|
515
|
+
'birthtimeMs': ms,
|
|
516
|
+
'atime': date,
|
|
517
|
+
'mtime': date,
|
|
518
|
+
'ctime': date,
|
|
519
|
+
'birthtime': date
|
|
520
|
+
};
|
|
521
|
+
}
|
|
399
522
|
let fpath = path.slice(8);
|
|
400
523
|
if (path.startsWith('/clickgo/')) {
|
|
401
524
|
if (!clickgoFiles.includes(fpath)) {
|
|
@@ -407,7 +530,35 @@ function stats(path, options = {}) {
|
|
|
407
530
|
return getClickGoStats(fpath);
|
|
408
531
|
}
|
|
409
532
|
else if (path.startsWith('/storage/')) {
|
|
410
|
-
|
|
533
|
+
const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
|
|
534
|
+
if (!r[0]) {
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
const item = yield native.invoke('cg-fs-stats', native.getToken(), fpath);
|
|
538
|
+
if (!item) {
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
isFile: function () {
|
|
543
|
+
return item.isFile;
|
|
544
|
+
},
|
|
545
|
+
isDirectory: function () {
|
|
546
|
+
return item.isDirectory;
|
|
547
|
+
},
|
|
548
|
+
isSymbolicLink: function () {
|
|
549
|
+
return item.isSymbolicLink;
|
|
550
|
+
},
|
|
551
|
+
'size': item.size,
|
|
552
|
+
'blksize': item.blksize,
|
|
553
|
+
'atimeMs': item.atimeMs,
|
|
554
|
+
'mtimeMs': item.mtimeMs,
|
|
555
|
+
'ctimeMs': item.ctimeMs,
|
|
556
|
+
'birthtimeMs': item.birthtimeMs,
|
|
557
|
+
'atime': item.atime,
|
|
558
|
+
'mtime': item.mtime,
|
|
559
|
+
'ctime': item.ctime,
|
|
560
|
+
'birthtime': item.birthtime
|
|
561
|
+
};
|
|
411
562
|
}
|
|
412
563
|
else if (path.startsWith('/mounted/')) {
|
|
413
564
|
const name = getMountName(path);
|
|
@@ -415,14 +566,45 @@ function stats(path, options = {}) {
|
|
|
415
566
|
if (!hanlder) {
|
|
416
567
|
return null;
|
|
417
568
|
}
|
|
418
|
-
|
|
569
|
+
if (path === '/mounted/' + name) {
|
|
570
|
+
const ms = hanlder.date.getTime();
|
|
571
|
+
return {
|
|
572
|
+
isFile: function () {
|
|
573
|
+
return false;
|
|
574
|
+
},
|
|
575
|
+
isDirectory: function () {
|
|
576
|
+
return true;
|
|
577
|
+
},
|
|
578
|
+
isSymbolicLink: function () {
|
|
579
|
+
return false;
|
|
580
|
+
},
|
|
581
|
+
'size': 0,
|
|
582
|
+
'blksize': 0,
|
|
583
|
+
'atimeMs': ms,
|
|
584
|
+
'mtimeMs': ms,
|
|
585
|
+
'ctimeMs': ms,
|
|
586
|
+
'birthtimeMs': ms,
|
|
587
|
+
'atime': hanlder.date,
|
|
588
|
+
'mtime': hanlder.date,
|
|
589
|
+
'ctime': hanlder.date,
|
|
590
|
+
'birthtime': hanlder.date
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
|
|
594
|
+
if (!r[0]) {
|
|
595
|
+
return null;
|
|
596
|
+
}
|
|
597
|
+
return (_b = (_a = hanlder.stats) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length))) !== null && _b !== void 0 ? _b : null;
|
|
419
598
|
}
|
|
420
|
-
else if (path.startsWith('/package/')) {
|
|
421
|
-
if (!
|
|
599
|
+
else if (path.startsWith('/package/') || path.startsWith('/current/')) {
|
|
600
|
+
if (!taskId) {
|
|
422
601
|
return null;
|
|
423
602
|
}
|
|
424
|
-
if (
|
|
425
|
-
|
|
603
|
+
if (path.startsWith('/current/')) {
|
|
604
|
+
return stats(task.list[taskId].current + fpath, taskId);
|
|
605
|
+
}
|
|
606
|
+
if (task.list[taskId].app.files[fpath]) {
|
|
607
|
+
const file = task.list[taskId].app.files[fpath];
|
|
426
608
|
const date = new Date();
|
|
427
609
|
const ms = date.getTime();
|
|
428
610
|
let size = 0;
|
|
@@ -457,7 +639,7 @@ function stats(path, options = {}) {
|
|
|
457
639
|
if (!fpath.endsWith('/')) {
|
|
458
640
|
fpath += '/';
|
|
459
641
|
}
|
|
460
|
-
for (const p in
|
|
642
|
+
for (const p in task.list[taskId].app.files) {
|
|
461
643
|
if (!p.startsWith(fpath)) {
|
|
462
644
|
continue;
|
|
463
645
|
}
|
|
@@ -487,70 +669,66 @@ function stats(path, options = {}) {
|
|
|
487
669
|
}
|
|
488
670
|
return null;
|
|
489
671
|
}
|
|
490
|
-
else if (path.startsWith('/current/')) {
|
|
491
|
-
if (!options.current) {
|
|
492
|
-
return null;
|
|
493
|
-
}
|
|
494
|
-
const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
|
|
495
|
-
return stats(current + fpath, options);
|
|
496
|
-
}
|
|
497
672
|
else {
|
|
498
673
|
return null;
|
|
499
674
|
}
|
|
500
675
|
});
|
|
501
676
|
}
|
|
502
677
|
exports.stats = stats;
|
|
503
|
-
function isDir(path,
|
|
678
|
+
function isDir(path, taskId) {
|
|
504
679
|
return __awaiter(this, void 0, void 0, function* () {
|
|
505
|
-
const pstats = yield stats(path,
|
|
506
|
-
if (!pstats ||
|
|
680
|
+
const pstats = yield stats(path, taskId);
|
|
681
|
+
if (!(pstats === null || pstats === void 0 ? void 0 : pstats.isDirectory())) {
|
|
507
682
|
return false;
|
|
508
683
|
}
|
|
509
684
|
return pstats;
|
|
510
685
|
});
|
|
511
686
|
}
|
|
512
687
|
exports.isDir = isDir;
|
|
513
|
-
function isFile(path,
|
|
688
|
+
function isFile(path, taskId) {
|
|
514
689
|
return __awaiter(this, void 0, void 0, function* () {
|
|
515
|
-
const pstats = yield stats(path,
|
|
516
|
-
if (!pstats ||
|
|
690
|
+
const pstats = yield stats(path, taskId);
|
|
691
|
+
if (!(pstats === null || pstats === void 0 ? void 0 : pstats.isFile())) {
|
|
517
692
|
return false;
|
|
518
693
|
}
|
|
519
694
|
return pstats;
|
|
520
695
|
});
|
|
521
696
|
}
|
|
522
697
|
exports.isFile = isFile;
|
|
523
|
-
function mkdir(path, mode = 0o755,
|
|
698
|
+
function mkdir(path, mode = 0o755, taskId) {
|
|
524
699
|
var _a, _b;
|
|
525
700
|
return __awaiter(this, void 0, void 0, function* () {
|
|
526
701
|
path = tool.urlResolve('/', path);
|
|
527
|
-
if (yield isDir(path,
|
|
702
|
+
if (yield isDir(path, taskId)) {
|
|
528
703
|
return true;
|
|
529
704
|
}
|
|
530
705
|
const fpath = path.slice(8);
|
|
531
706
|
if (path.startsWith('/clickgo/')) {
|
|
532
707
|
return false;
|
|
533
708
|
}
|
|
534
|
-
else if (path.startsWith('/storage/')) {
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
else if (path.startsWith('/mounted/')) {
|
|
538
|
-
const name = getMountName(path);
|
|
539
|
-
const hanlder = mounts[name];
|
|
540
|
-
if (!hanlder) {
|
|
709
|
+
else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
|
|
710
|
+
const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
|
|
711
|
+
if (!r[0]) {
|
|
541
712
|
return false;
|
|
542
713
|
}
|
|
543
|
-
|
|
714
|
+
if (path.startsWith('/mounted/')) {
|
|
715
|
+
const name = getMountName(path);
|
|
716
|
+
const hanlder = mounts[name];
|
|
717
|
+
if (!hanlder) {
|
|
718
|
+
return false;
|
|
719
|
+
}
|
|
720
|
+
return (_b = (_a = hanlder.mkdir) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), mode)) !== null && _b !== void 0 ? _b : false;
|
|
721
|
+
}
|
|
722
|
+
return native.invoke('cg-fs-mkdir', native.getToken(), fpath, mode);
|
|
544
723
|
}
|
|
545
724
|
else if (path.startsWith('/package/')) {
|
|
546
725
|
return false;
|
|
547
726
|
}
|
|
548
727
|
else if (path.startsWith('/current/')) {
|
|
549
|
-
if (!
|
|
728
|
+
if (!taskId) {
|
|
550
729
|
return false;
|
|
551
730
|
}
|
|
552
|
-
|
|
553
|
-
return mkdir(current + fpath, mode, options);
|
|
731
|
+
return mkdir(task.list[taskId].current + fpath, mode, taskId);
|
|
554
732
|
}
|
|
555
733
|
else {
|
|
556
734
|
return false;
|
|
@@ -558,7 +736,7 @@ function mkdir(path, mode = 0o755, options = {}) {
|
|
|
558
736
|
});
|
|
559
737
|
}
|
|
560
738
|
exports.mkdir = mkdir;
|
|
561
|
-
function rmdir(path,
|
|
739
|
+
function rmdir(path, taskId) {
|
|
562
740
|
var _a, _b;
|
|
563
741
|
return __awaiter(this, void 0, void 0, function* () {
|
|
564
742
|
path = tool.urlResolve('/', path);
|
|
@@ -566,26 +744,29 @@ function rmdir(path, options = {}) {
|
|
|
566
744
|
if (path.startsWith('/clickgo/')) {
|
|
567
745
|
return false;
|
|
568
746
|
}
|
|
569
|
-
else if (path.startsWith('/storage/')) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
else if (path.startsWith('/mounted/')) {
|
|
573
|
-
const name = getMountName(path);
|
|
574
|
-
const hanlder = mounts[name];
|
|
575
|
-
if (!hanlder) {
|
|
747
|
+
else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
|
|
748
|
+
const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
|
|
749
|
+
if (!r[0]) {
|
|
576
750
|
return false;
|
|
577
751
|
}
|
|
578
|
-
|
|
752
|
+
if (path.startsWith('/mounted/')) {
|
|
753
|
+
const name = getMountName(path);
|
|
754
|
+
const hanlder = mounts[name];
|
|
755
|
+
if (!hanlder) {
|
|
756
|
+
return false;
|
|
757
|
+
}
|
|
758
|
+
return (_b = (_a = hanlder.rmdir) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length))) !== null && _b !== void 0 ? _b : false;
|
|
759
|
+
}
|
|
760
|
+
return native.invoke('cg-fs-rmdir', native.getToken(), fpath);
|
|
579
761
|
}
|
|
580
762
|
else if (path.startsWith('/package/')) {
|
|
581
763
|
return false;
|
|
582
764
|
}
|
|
583
765
|
else if (path.startsWith('/current/')) {
|
|
584
|
-
if (!
|
|
766
|
+
if (!taskId) {
|
|
585
767
|
return false;
|
|
586
768
|
}
|
|
587
|
-
|
|
588
|
-
return rmdir(current + fpath, options);
|
|
769
|
+
return rmdir(task.list[taskId].current + fpath, taskId);
|
|
589
770
|
}
|
|
590
771
|
else {
|
|
591
772
|
return false;
|
|
@@ -593,36 +774,36 @@ function rmdir(path, options = {}) {
|
|
|
593
774
|
});
|
|
594
775
|
}
|
|
595
776
|
exports.rmdir = rmdir;
|
|
596
|
-
function rmdirDeep(path,
|
|
777
|
+
function rmdirDeep(path, taskId) {
|
|
597
778
|
return __awaiter(this, void 0, void 0, function* () {
|
|
598
779
|
path = tool.urlResolve('/', path);
|
|
599
780
|
if (!path.endsWith('/')) {
|
|
600
781
|
path += '/';
|
|
601
782
|
}
|
|
602
|
-
const list = yield readDir(path,
|
|
783
|
+
const list = yield readDir(path, undefined, taskId);
|
|
603
784
|
for (const item of list) {
|
|
604
|
-
const stat = yield stats(path + item.name,
|
|
785
|
+
const stat = yield stats(path + item.name, taskId);
|
|
605
786
|
if (!stat) {
|
|
606
787
|
return false;
|
|
607
788
|
}
|
|
608
789
|
if (stat.isDirectory()) {
|
|
609
|
-
const rtn = yield rmdirDeep(path + item.name,
|
|
790
|
+
const rtn = yield rmdirDeep(path + item.name, taskId);
|
|
610
791
|
if (!rtn) {
|
|
611
792
|
return false;
|
|
612
793
|
}
|
|
613
794
|
}
|
|
614
795
|
else {
|
|
615
|
-
const rtn = yield unlink(path + item.name,
|
|
796
|
+
const rtn = yield unlink(path + item.name, taskId);
|
|
616
797
|
if (!rtn) {
|
|
617
798
|
return false;
|
|
618
799
|
}
|
|
619
800
|
}
|
|
620
801
|
}
|
|
621
|
-
return rmdir(path,
|
|
802
|
+
return rmdir(path, taskId);
|
|
622
803
|
});
|
|
623
804
|
}
|
|
624
805
|
exports.rmdirDeep = rmdirDeep;
|
|
625
|
-
function chmod(path, mod,
|
|
806
|
+
function chmod(path, mod, taskId) {
|
|
626
807
|
var _a, _b;
|
|
627
808
|
return __awaiter(this, void 0, void 0, function* () {
|
|
628
809
|
path = tool.urlResolve('/', path);
|
|
@@ -630,26 +811,29 @@ function chmod(path, mod, options = {}) {
|
|
|
630
811
|
if (path.startsWith('/clickgo/')) {
|
|
631
812
|
return false;
|
|
632
813
|
}
|
|
633
|
-
else if (path.startsWith('/storage/')) {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
else if (path.startsWith('/mounted/')) {
|
|
637
|
-
const name = getMountName(path);
|
|
638
|
-
const hanlder = mounts[name];
|
|
639
|
-
if (!hanlder) {
|
|
814
|
+
else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
|
|
815
|
+
const r = yield task.checkPermission('fs.' + path + 'w', false, undefined, taskId);
|
|
816
|
+
if (!r[0]) {
|
|
640
817
|
return false;
|
|
641
818
|
}
|
|
642
|
-
|
|
819
|
+
if (path.startsWith('/mounted/')) {
|
|
820
|
+
const name = getMountName(path);
|
|
821
|
+
const hanlder = mounts[name];
|
|
822
|
+
if (!hanlder) {
|
|
823
|
+
return false;
|
|
824
|
+
}
|
|
825
|
+
return (_b = (_a = hanlder.chmod) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), mod)) !== null && _b !== void 0 ? _b : false;
|
|
826
|
+
}
|
|
827
|
+
return native.invoke('cg-fs-chmod', native.getToken(), fpath, mod);
|
|
643
828
|
}
|
|
644
829
|
else if (path.startsWith('/package/')) {
|
|
645
830
|
return false;
|
|
646
831
|
}
|
|
647
832
|
else if (path.startsWith('/current/')) {
|
|
648
|
-
if (!
|
|
833
|
+
if (!taskId) {
|
|
649
834
|
return false;
|
|
650
835
|
}
|
|
651
|
-
|
|
652
|
-
return chmod(current + fpath, mod, options);
|
|
836
|
+
return chmod(task.list[taskId].current + fpath, mod, taskId);
|
|
653
837
|
}
|
|
654
838
|
else {
|
|
655
839
|
return false;
|
|
@@ -657,7 +841,8 @@ function chmod(path, mod, options = {}) {
|
|
|
657
841
|
});
|
|
658
842
|
}
|
|
659
843
|
exports.chmod = chmod;
|
|
660
|
-
function rename(oldPath, newPath,
|
|
844
|
+
function rename(oldPath, newPath, taskId) {
|
|
845
|
+
var _a, _b;
|
|
661
846
|
return __awaiter(this, void 0, void 0, function* () {
|
|
662
847
|
oldPath = tool.urlResolve('/', oldPath);
|
|
663
848
|
newPath = tool.urlResolve('/', newPath);
|
|
@@ -669,21 +854,37 @@ function rename(oldPath, newPath, options = {}) {
|
|
|
669
854
|
if (oldPath.startsWith('/clickgo/')) {
|
|
670
855
|
return false;
|
|
671
856
|
}
|
|
672
|
-
else if (oldPath.startsWith('/storage/')) {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
857
|
+
else if (oldPath.startsWith('/storage/') || oldPath.startsWith('/mounted/')) {
|
|
858
|
+
let r = yield task.checkPermission('fs.' + oldPath + 'w', false, undefined, taskId);
|
|
859
|
+
if (!r[0]) {
|
|
860
|
+
return false;
|
|
861
|
+
}
|
|
862
|
+
r = yield task.checkPermission('fs.' + newPath + 'w', false, undefined, taskId);
|
|
863
|
+
if (!r[0]) {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
if (oldPath.startsWith('/mounted/')) {
|
|
867
|
+
const fname = getMountName(oldPath);
|
|
868
|
+
const lname = getMountName(newPath);
|
|
869
|
+
if (fname !== lname) {
|
|
870
|
+
return false;
|
|
871
|
+
}
|
|
872
|
+
const hanlder = mounts[fname];
|
|
873
|
+
if (!hanlder) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
return (_b = (_a = hanlder.rename) === null || _a === void 0 ? void 0 : _a.call(hanlder, oldPath.slice(9 + fname.length), newPath.slice(9 + fname.length))) !== null && _b !== void 0 ? _b : false;
|
|
877
|
+
}
|
|
878
|
+
return native.invoke('cg-fs-rename', native.getToken(), ofpath, nfpath);
|
|
677
879
|
}
|
|
678
880
|
else if (oldPath.startsWith('/package/')) {
|
|
679
881
|
return false;
|
|
680
882
|
}
|
|
681
883
|
else if (oldPath.startsWith('/current/')) {
|
|
682
|
-
if (!
|
|
884
|
+
if (!taskId) {
|
|
683
885
|
return false;
|
|
684
886
|
}
|
|
685
|
-
|
|
686
|
-
return rename(current + ofpath, current + nfpath, options);
|
|
887
|
+
return rename(task.list[taskId].current + ofpath, task.list[taskId].current + nfpath, taskId);
|
|
687
888
|
}
|
|
688
889
|
else {
|
|
689
890
|
return false;
|
|
@@ -691,7 +892,8 @@ function rename(oldPath, newPath, options = {}) {
|
|
|
691
892
|
});
|
|
692
893
|
}
|
|
693
894
|
exports.rename = rename;
|
|
694
|
-
function readDir(path,
|
|
895
|
+
function readDir(path, encoding, taskId) {
|
|
896
|
+
var _a, _b;
|
|
695
897
|
return __awaiter(this, void 0, void 0, function* () {
|
|
696
898
|
path = tool.urlResolve('/', path);
|
|
697
899
|
if (path === '/') {
|
|
@@ -733,7 +935,7 @@ function readDir(path, options = {}) {
|
|
|
733
935
|
'name': 'mounted'
|
|
734
936
|
}
|
|
735
937
|
];
|
|
736
|
-
if (
|
|
938
|
+
if (taskId) {
|
|
737
939
|
list.push({
|
|
738
940
|
isFile: function () {
|
|
739
941
|
return false;
|
|
@@ -747,7 +949,7 @@ function readDir(path, options = {}) {
|
|
|
747
949
|
'name': 'package'
|
|
748
950
|
});
|
|
749
951
|
}
|
|
750
|
-
if (
|
|
952
|
+
if (taskId) {
|
|
751
953
|
list.push({
|
|
752
954
|
isFile: function () {
|
|
753
955
|
return false;
|
|
@@ -812,19 +1014,64 @@ function readDir(path, options = {}) {
|
|
|
812
1014
|
}
|
|
813
1015
|
return list;
|
|
814
1016
|
}
|
|
815
|
-
else if (path.startsWith('/storage/')) {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
1017
|
+
else if (path.startsWith('/storage/') || path.startsWith('/mounted/')) {
|
|
1018
|
+
const list = [];
|
|
1019
|
+
if (path === '/mounted/') {
|
|
1020
|
+
for (const name in mounts) {
|
|
1021
|
+
list.push({
|
|
1022
|
+
isFile: function () {
|
|
1023
|
+
return false;
|
|
1024
|
+
},
|
|
1025
|
+
isDirectory: function () {
|
|
1026
|
+
return true;
|
|
1027
|
+
},
|
|
1028
|
+
isSymbolicLink: function () {
|
|
1029
|
+
return false;
|
|
1030
|
+
},
|
|
1031
|
+
'name': name
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
return list;
|
|
1035
|
+
}
|
|
1036
|
+
const r = yield task.checkPermission('fs.' + path + 'r', false, undefined, taskId);
|
|
1037
|
+
if (!r[0]) {
|
|
1038
|
+
return [];
|
|
1039
|
+
}
|
|
1040
|
+
if (path.startsWith('/mounted/')) {
|
|
1041
|
+
const name = getMountName(path);
|
|
1042
|
+
const hanlder = mounts[name];
|
|
1043
|
+
if (!hanlder) {
|
|
1044
|
+
return [];
|
|
1045
|
+
}
|
|
1046
|
+
return (_b = (_a = hanlder.readDir) === null || _a === void 0 ? void 0 : _a.call(hanlder, path.slice(9 + name.length), encoding)) !== null && _b !== void 0 ? _b : [];
|
|
1047
|
+
}
|
|
1048
|
+
const ls = yield native.invoke('cg-fs-readDir', native.getToken(), fpath, encoding);
|
|
1049
|
+
for (const item of ls) {
|
|
1050
|
+
list.push({
|
|
1051
|
+
isFile: function () {
|
|
1052
|
+
return item.isFile;
|
|
1053
|
+
},
|
|
1054
|
+
isDirectory: function () {
|
|
1055
|
+
return item.isDirectory;
|
|
1056
|
+
},
|
|
1057
|
+
isSymbolicLink: function () {
|
|
1058
|
+
return item.isSymbolicLink;
|
|
1059
|
+
},
|
|
1060
|
+
'name': item.name
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
return list;
|
|
820
1064
|
}
|
|
821
|
-
else if (path.startsWith('/package/')) {
|
|
822
|
-
if (!
|
|
1065
|
+
else if (path.startsWith('/package/') || path.startsWith('/current/')) {
|
|
1066
|
+
if (!taskId) {
|
|
823
1067
|
return [];
|
|
824
1068
|
}
|
|
1069
|
+
if (path.startsWith('/current/')) {
|
|
1070
|
+
return readDir(task.list[taskId].current + fpath, encoding, taskId);
|
|
1071
|
+
}
|
|
825
1072
|
const list = [];
|
|
826
1073
|
const dirs = [];
|
|
827
|
-
for (const p in
|
|
1074
|
+
for (const p in task.list[taskId].app.files) {
|
|
828
1075
|
if (!p.startsWith(fpath)) {
|
|
829
1076
|
continue;
|
|
830
1077
|
}
|
|
@@ -864,54 +1111,52 @@ function readDir(path, options = {}) {
|
|
|
864
1111
|
}
|
|
865
1112
|
return list;
|
|
866
1113
|
}
|
|
867
|
-
else if (path.startsWith('/current/')) {
|
|
868
|
-
if (!options.current) {
|
|
869
|
-
return [];
|
|
870
|
-
}
|
|
871
|
-
const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
|
|
872
|
-
return readDir(current + fpath, options);
|
|
873
|
-
}
|
|
874
1114
|
else {
|
|
875
1115
|
return [];
|
|
876
1116
|
}
|
|
877
1117
|
});
|
|
878
1118
|
}
|
|
879
1119
|
exports.readDir = readDir;
|
|
880
|
-
function copyFolder(from, to,
|
|
1120
|
+
function copyFolder(from, to, ignore = [], taskId) {
|
|
881
1121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if (!from.startsWith(to.slice(0, 9))) {
|
|
885
|
-
return 0;
|
|
886
|
-
}
|
|
887
|
-
const ffpath = from.slice(8);
|
|
888
|
-
const tfpath = from.slice(8);
|
|
889
|
-
if (from.startsWith('/clickgo/')) {
|
|
890
|
-
return 0;
|
|
891
|
-
}
|
|
892
|
-
else if (from.startsWith('/storage/')) {
|
|
893
|
-
return 0;
|
|
894
|
-
}
|
|
895
|
-
else if (from.startsWith('/mounted/')) {
|
|
896
|
-
return 0;
|
|
897
|
-
}
|
|
898
|
-
else if (from.startsWith('/package/')) {
|
|
1122
|
+
let num = 0;
|
|
1123
|
+
if (!(yield isDir(from, taskId))) {
|
|
899
1124
|
return 0;
|
|
900
1125
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
1126
|
+
const flist = yield readDir(from, undefined, taskId);
|
|
1127
|
+
let checkTo = false;
|
|
1128
|
+
for (const item of flist) {
|
|
1129
|
+
if (item.isDirectory()) {
|
|
1130
|
+
const r = yield copyFolder(from + item.name + '/', to + item.name + '/', ignore, taskId);
|
|
1131
|
+
if (r === -1) {
|
|
1132
|
+
return r;
|
|
1133
|
+
}
|
|
1134
|
+
else {
|
|
1135
|
+
num += r;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
else if (item.isFile()) {
|
|
1139
|
+
if (ignore.length > 0 && tool.match(item.name, ignore)) {
|
|
1140
|
+
continue;
|
|
1141
|
+
}
|
|
1142
|
+
if (!checkTo) {
|
|
1143
|
+
if (!(yield mkdir(to, undefined, taskId))) {
|
|
1144
|
+
return -1;
|
|
1145
|
+
}
|
|
1146
|
+
checkTo = true;
|
|
1147
|
+
}
|
|
1148
|
+
if (!(yield copyFile(from + item.name, to + item.name, taskId))) {
|
|
1149
|
+
continue;
|
|
1150
|
+
}
|
|
1151
|
+
++num;
|
|
904
1152
|
}
|
|
905
|
-
const current = options.current.endsWith('/') ? options.current.slice(0, -1) : options.current;
|
|
906
|
-
return copyFolder(current + ffpath, current + tfpath, options);
|
|
907
|
-
}
|
|
908
|
-
else {
|
|
909
|
-
return 0;
|
|
910
1153
|
}
|
|
1154
|
+
return num;
|
|
911
1155
|
});
|
|
912
1156
|
}
|
|
913
1157
|
exports.copyFolder = copyFolder;
|
|
914
|
-
function copyFile(src, dest,
|
|
1158
|
+
function copyFile(src, dest, taskId) {
|
|
1159
|
+
var _a, _b;
|
|
915
1160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
916
1161
|
src = tool.urlResolve('/', src);
|
|
917
1162
|
dest = tool.urlResolve('/', dest);
|
|
@@ -923,21 +1168,37 @@ function copyFile(src, dest, options = {}) {
|
|
|
923
1168
|
if (src.startsWith('/clickgo/')) {
|
|
924
1169
|
return false;
|
|
925
1170
|
}
|
|
926
|
-
else if (src.startsWith('/storage/')) {
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1171
|
+
else if (src.startsWith('/storage/') || dest.startsWith('/mounted/')) {
|
|
1172
|
+
let r = yield task.checkPermission('fs.' + src + 'r', false, undefined, taskId);
|
|
1173
|
+
if (!r[0]) {
|
|
1174
|
+
return false;
|
|
1175
|
+
}
|
|
1176
|
+
r = yield task.checkPermission('fs.' + dest + 'w', false, undefined, taskId);
|
|
1177
|
+
if (!r[0]) {
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
if (src.startsWith('/mounted/')) {
|
|
1181
|
+
const fname = getMountName(src);
|
|
1182
|
+
const lname = getMountName(dest);
|
|
1183
|
+
if (fname !== lname) {
|
|
1184
|
+
return false;
|
|
1185
|
+
}
|
|
1186
|
+
const hanlder = mounts[fname];
|
|
1187
|
+
if (!hanlder) {
|
|
1188
|
+
return false;
|
|
1189
|
+
}
|
|
1190
|
+
return (_b = (_a = hanlder.copyFile) === null || _a === void 0 ? void 0 : _a.call(hanlder, src.slice(9 + fname.length), dest.slice(9 + fname.length))) !== null && _b !== void 0 ? _b : false;
|
|
1191
|
+
}
|
|
1192
|
+
return native.invoke('cg-fs-copyFile', native.getToken(), sfpath, dfpath);
|
|
931
1193
|
}
|
|
932
1194
|
else if (src.startsWith('/package/')) {
|
|
933
1195
|
return false;
|
|
934
1196
|
}
|
|
935
1197
|
else if (src.startsWith('/current/')) {
|
|
936
|
-
if (!
|
|
1198
|
+
if (!taskId) {
|
|
937
1199
|
return false;
|
|
938
1200
|
}
|
|
939
|
-
|
|
940
|
-
return copyFile(current + sfpath, current + dfpath, options);
|
|
1201
|
+
return copyFile(task.list[taskId].current + sfpath, task.list[taskId].current + dfpath, taskId);
|
|
941
1202
|
}
|
|
942
1203
|
else {
|
|
943
1204
|
return false;
|