filefive 1.8.0 → 2.0.0
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/dist/App.js +6 -8
- package/dist/Connection.js +7 -8
- package/dist/FileWatcher.js +4 -5
- package/dist/Local.js +62 -22
- package/dist/LocalWatcher.js +21 -16
- package/dist/Password.js +5 -5
- package/dist/Queue.js +8 -8
- package/dist/RemoteFiles.js +5 -5
- package/dist/RemoteWatcher.js +1 -2
- package/dist/commands/checkVer.js +6 -3
- package/dist/commands/clear.js +2 -2
- package/dist/commands/connect.js +9 -8
- package/dist/commands/duplicate.js +2 -2
- package/dist/commands/mkdir.js +4 -4
- package/dist/commands/open.js +3 -2
- package/dist/commands/remove.js +2 -3
- package/dist/commands/rename.js +3 -3
- package/dist/commands/saveConnection.js +4 -6
- package/dist/commands/saveSettings.js +2 -2
- package/dist/commands/settings.js +7 -6
- package/dist/commands/write.js +2 -2
- package/dist/fs/Ftp.js +8 -7
- package/dist/fs/Local.js +7 -7
- package/dist/fs/S3.js +12 -11
- package/dist/fs/SFtp.js +11 -10
- package/dist/index.js +9 -8
- package/dist/public/index.js +1 -1
- package/dist/queues/Copy.js +5 -5
- package/dist/queues/Download.js +2 -2
- package/dist/queues/Queue.js +9 -9
- package/dist/queues/Remove.js +4 -4
- package/dist/queues/Upload.js +3 -3
- package/dist/transformers/git.js +11 -10
- package/dist/utils/os.js +17 -0
- package/dist/utils/path.js +4 -4
- package/dist/win.js +20 -0
- package/package.json +13 -13
|
@@ -5,11 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getSettings = getSettings;
|
|
7
7
|
exports.default = default_1;
|
|
8
|
-
const Local_1 = require("../Local");
|
|
9
8
|
const URI_1 = require("../utils/URI");
|
|
10
|
-
const
|
|
9
|
+
const Local_1 = require("../Local");
|
|
11
10
|
const ramda_1 = require("ramda");
|
|
12
|
-
const promises_1 = require("node:fs/promises");
|
|
13
11
|
const Password_1 = __importDefault(require("../Password"));
|
|
14
12
|
function getSettings(settings) {
|
|
15
13
|
return {
|
|
@@ -20,8 +18,8 @@ function getSettings(settings) {
|
|
|
20
18
|
};
|
|
21
19
|
}
|
|
22
20
|
async function default_1(path, settings) {
|
|
23
|
-
const content = (0,
|
|
24
|
-
if ((0,
|
|
21
|
+
const content = (0, Local_1.stat)(path) ? await (0, Local_1.read)(path) : null;
|
|
22
|
+
if ((0, Local_1.stat)(path) && !content) {
|
|
25
23
|
throw new Error(`Cant read connection file: ${path} ${typeof content}`);
|
|
26
24
|
}
|
|
27
25
|
let config = content ? JSON.parse(content) : {};
|
|
@@ -48,5 +46,5 @@ async function default_1(path, settings) {
|
|
|
48
46
|
if (!config) {
|
|
49
47
|
throw new Error(`Save invalid config into ${path}`);
|
|
50
48
|
}
|
|
51
|
-
await (0,
|
|
49
|
+
await (0, Local_1.write)(path, JSON.stringify(config));
|
|
52
50
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = default_1;
|
|
4
|
-
const
|
|
4
|
+
const Local_1 = require("../Local");
|
|
5
5
|
const saveConnection_1 = require("./saveConnection");
|
|
6
6
|
const ramda_1 = require("ramda");
|
|
7
7
|
const _1 = require(".");
|
|
@@ -18,5 +18,5 @@ async function default_1(path, changes) {
|
|
|
18
18
|
path: settings.path,
|
|
19
19
|
sync: settings.sync
|
|
20
20
|
};
|
|
21
|
-
await (0,
|
|
21
|
+
await (0, Local_1.write)(path, JSON.stringify(config));
|
|
22
22
|
}
|
|
@@ -4,8 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
|
-
const
|
|
8
|
-
const node_path_1 = require("node:path");
|
|
7
|
+
const posix_1 = require("node:path/posix");
|
|
9
8
|
const Local_1 = require("../Local");
|
|
10
9
|
const Local_2 = require("../fs/Local");
|
|
11
10
|
const connect_1 = require("./connect");
|
|
@@ -20,10 +19,12 @@ async function default_1(path) {
|
|
|
20
19
|
config = JSON.parse(await (0, Local_1.read)(path));
|
|
21
20
|
}
|
|
22
21
|
catch (e) { }
|
|
22
|
+
const home = (0, Local_1.pwd)();
|
|
23
23
|
const settings = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
isWin: (0, Local_1.isWin)(),
|
|
25
|
+
home,
|
|
26
|
+
settings: (0, posix_1.join)(home, '.f5', 'settings.json'),
|
|
27
|
+
connections: (0, posix_1.join)(home, '.f5', 'connections'),
|
|
27
28
|
keybindings: keybindings_json_1.default,
|
|
28
29
|
mode: config?.mode ?? 'system',
|
|
29
30
|
theme: config?.theme ?? 'black',
|
|
@@ -32,7 +33,7 @@ async function default_1(path) {
|
|
|
32
33
|
sizeFmt: config?.sizeFmt ?? '0.0 b',
|
|
33
34
|
local: (0, connect_1.explorerSettings)(Local_2.ATTRIBUTES, config?.local),
|
|
34
35
|
remote: (0, connect_1.explorerSettings)(Local_2.ATTRIBUTES, config?.remote),
|
|
35
|
-
path: config?.path ?? { local:
|
|
36
|
+
path: config?.path ?? { local: home, remote: home },
|
|
36
37
|
sync: config?.sync ?? null
|
|
37
38
|
};
|
|
38
39
|
if (settings.fileTheme) {
|
package/dist/commands/write.js
CHANGED
|
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.default = default_1;
|
|
7
7
|
const Connection_1 = __importDefault(require("../Connection"));
|
|
8
8
|
const URI_1 = require("../utils/URI");
|
|
9
|
-
const
|
|
9
|
+
const posix_1 = require("node:path/posix");
|
|
10
10
|
const App_1 = __importDefault(require("../App"));
|
|
11
11
|
async function default_1(file, content) {
|
|
12
12
|
const { id, path } = (0, URI_1.parseURI)(file);
|
|
13
13
|
await Connection_1.default.get(id).write(path, content);
|
|
14
14
|
if (!(0, URI_1.isLocal)(file)) {
|
|
15
|
-
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0,
|
|
15
|
+
App_1.default.remoteWatcher.refresh((0, URI_1.createURI)(id, (0, posix_1.dirname)(path)));
|
|
16
16
|
}
|
|
17
17
|
}
|
package/dist/fs/Ftp.js
CHANGED
|
@@ -37,12 +37,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.ATTRIBUTES = void 0;
|
|
40
|
-
const
|
|
40
|
+
const posix_1 = require("node:path/posix");
|
|
41
41
|
const node_os_1 = require("node:os");
|
|
42
42
|
const promises_1 = require("node:fs/promises");
|
|
43
43
|
const fs = __importStar(require("fs"));
|
|
44
44
|
const ftp_1 = __importDefault(require("ftp"));
|
|
45
45
|
const FileSystem_1 = require("../FileSystem");
|
|
46
|
+
const Local_1 = require("../Local");
|
|
46
47
|
// https://github.com/mscdex/node-ftp
|
|
47
48
|
exports.ATTRIBUTES = [
|
|
48
49
|
{
|
|
@@ -118,11 +119,11 @@ class Ftp extends FileSystem_1.FileSystem {
|
|
|
118
119
|
.filter(f => f.name != '.' && f.name != '..')
|
|
119
120
|
.map(f => {
|
|
120
121
|
let target = f.target;
|
|
121
|
-
if (target && !(0,
|
|
122
|
-
target = (0,
|
|
122
|
+
if (target && !(0, posix_1.isAbsolute)(target)) {
|
|
123
|
+
target = (0, posix_1.normalize)((0, posix_1.join)(dir, target));
|
|
123
124
|
}
|
|
124
125
|
return {
|
|
125
|
-
path: (0,
|
|
126
|
+
path: (0, posix_1.join)(dir, f.name),
|
|
126
127
|
name: f.name,
|
|
127
128
|
dir: f.type == 'd',
|
|
128
129
|
size: f.size,
|
|
@@ -144,7 +145,7 @@ class Ftp extends FileSystem_1.FileSystem {
|
|
|
144
145
|
reject(err);
|
|
145
146
|
}
|
|
146
147
|
else {
|
|
147
|
-
const dest = fs.createWriteStream(toLocal);
|
|
148
|
+
const dest = fs.createWriteStream((0, Local_1.osify)(toLocal));
|
|
148
149
|
dest.on('finish', () => resolve());
|
|
149
150
|
source.pipe(dest);
|
|
150
151
|
}
|
|
@@ -154,7 +155,7 @@ class Ftp extends FileSystem_1.FileSystem {
|
|
|
154
155
|
async put(fromLocal, toRemote) {
|
|
155
156
|
await this.open();
|
|
156
157
|
return new Promise((resolve, reject) => {
|
|
157
|
-
this.connection.put(fromLocal, toRemote, e => e ? reject(e) : resolve());
|
|
158
|
+
this.connection.put((0, Local_1.osify)(fromLocal), toRemote, e => e ? reject(e) : resolve());
|
|
158
159
|
});
|
|
159
160
|
}
|
|
160
161
|
async rm(path, recursive) {
|
|
@@ -179,7 +180,7 @@ class Ftp extends FileSystem_1.FileSystem {
|
|
|
179
180
|
return Promise.reject(new Error("FTP doesn't support remote duplication"));
|
|
180
181
|
}
|
|
181
182
|
async write(path, s) {
|
|
182
|
-
const tmp = (0,
|
|
183
|
+
const tmp = (0, posix_1.join)((0, node_os_1.tmpdir)(), (0, posix_1.basename)(path));
|
|
183
184
|
await (0, promises_1.writeFile)(tmp, s);
|
|
184
185
|
await this.put(tmp, path);
|
|
185
186
|
(0, promises_1.rm)(tmp);
|
package/dist/fs/Local.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ATTRIBUTES = void 0;
|
|
4
4
|
const promises_1 = require("node:fs/promises");
|
|
5
|
-
const
|
|
5
|
+
const posix_1 = require("node:path/posix");
|
|
6
6
|
const FileSystem_1 = require("../FileSystem");
|
|
7
7
|
const Local_1 = require("../Local");
|
|
8
8
|
const types_1 = require("../types");
|
|
@@ -45,24 +45,24 @@ class Local extends FileSystem_1.FileSystem {
|
|
|
45
45
|
return (0, Local_1.del)(path);
|
|
46
46
|
}
|
|
47
47
|
async mkdir(path) {
|
|
48
|
-
await (0,
|
|
48
|
+
await (0, Local_1.mkDirRecursive)(path);
|
|
49
49
|
}
|
|
50
50
|
async rename(from, to) {
|
|
51
|
-
await (0,
|
|
51
|
+
await (0, Local_1.move)(from, to);
|
|
52
52
|
}
|
|
53
53
|
async mv(from, to) {
|
|
54
54
|
try {
|
|
55
55
|
await (0, Local_1.del)(to);
|
|
56
56
|
}
|
|
57
57
|
catch (e) { }
|
|
58
|
-
await (0,
|
|
59
|
-
await (0,
|
|
58
|
+
await (0, Local_1.mkDirRecursive)((0, posix_1.dirname)(to));
|
|
59
|
+
await (0, Local_1.move)(from, to);
|
|
60
60
|
}
|
|
61
61
|
async cp(from, to, recursive) {
|
|
62
|
-
await (0, promises_1.cp)(from, to, { recursive, force: true });
|
|
62
|
+
await (0, promises_1.cp)((0, Local_1.osify)(from), (0, Local_1.osify)(to), { recursive, force: true });
|
|
63
63
|
}
|
|
64
64
|
async write(path, data) {
|
|
65
|
-
return (0,
|
|
65
|
+
return (0, Local_1.write)(path, data);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
exports.default = Local;
|
package/dist/fs/S3.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ATTRIBUTES = void 0;
|
|
4
|
-
const
|
|
4
|
+
const posix_1 = require("node:path/posix");
|
|
5
5
|
const node_fs_1 = require("node:fs");
|
|
6
6
|
const path_1 = require("../utils/path");
|
|
7
|
+
const Local_1 = require("../Local");
|
|
7
8
|
const FileSystem_1 = require("../FileSystem");
|
|
8
9
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
9
10
|
// https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/
|
|
@@ -79,8 +80,8 @@ class S3 extends FileSystem_1.FileSystem {
|
|
|
79
80
|
}));
|
|
80
81
|
return [
|
|
81
82
|
...(output.CommonPrefixes ?? []).map(prefix => ({
|
|
82
|
-
path: (0,
|
|
83
|
-
name: (0,
|
|
83
|
+
path: (0, posix_1.resolve)('/', parts[0], prefix.Prefix),
|
|
84
|
+
name: (0, posix_1.basename)(prefix.Prefix),
|
|
84
85
|
dir: true,
|
|
85
86
|
size: 0,
|
|
86
87
|
modified: new Date()
|
|
@@ -88,8 +89,8 @@ class S3 extends FileSystem_1.FileSystem {
|
|
|
88
89
|
...(output.Contents ?? [])
|
|
89
90
|
.filter(({ Key }) => Key != target)
|
|
90
91
|
.map(item => ({
|
|
91
|
-
path: (0,
|
|
92
|
-
name: (0,
|
|
92
|
+
path: (0, posix_1.resolve)('/', parts[0], item.Key),
|
|
93
|
+
name: (0, posix_1.basename)(item.Key),
|
|
93
94
|
dir: false,
|
|
94
95
|
size: item.Size,
|
|
95
96
|
modified: new Date(item.LastModified)
|
|
@@ -104,7 +105,7 @@ class S3 extends FileSystem_1.FileSystem {
|
|
|
104
105
|
}));
|
|
105
106
|
if (output.Body) {
|
|
106
107
|
const body = output.Body;
|
|
107
|
-
const writeStream = (0, node_fs_1.createWriteStream)(toLocal);
|
|
108
|
+
const writeStream = (0, node_fs_1.createWriteStream)((0, Local_1.osify)(toLocal));
|
|
108
109
|
body.pipe(writeStream);
|
|
109
110
|
return new Promise((resolve, reject) => {
|
|
110
111
|
writeStream.on('finish', resolve);
|
|
@@ -120,7 +121,7 @@ class S3 extends FileSystem_1.FileSystem {
|
|
|
120
121
|
Key: parts.slice(1).join('/')
|
|
121
122
|
}));
|
|
122
123
|
const partSize = 5 * 1024 * 1024;
|
|
123
|
-
const fromStream = (0, node_fs_1.createReadStream)(fromLocal, { highWaterMark: partSize });
|
|
124
|
+
const fromStream = (0, node_fs_1.createReadStream)((0, Local_1.osify)(fromLocal), { highWaterMark: partSize });
|
|
124
125
|
let buffer = [];
|
|
125
126
|
let partNumber = 1;
|
|
126
127
|
const uploadParts = [];
|
|
@@ -176,7 +177,7 @@ class S3 extends FileSystem_1.FileSystem {
|
|
|
176
177
|
return this.mv(from, to);
|
|
177
178
|
}
|
|
178
179
|
async mv(from, to) {
|
|
179
|
-
const isDir = (await this.ls((0,
|
|
180
|
+
const isDir = (await this.ls((0, posix_1.dirname)(from))).find(({ path }) => path == from)?.dir ?? false;
|
|
180
181
|
await this.cp(from, to, isDir);
|
|
181
182
|
const recursiveRm = async (path) => {
|
|
182
183
|
await Promise.all((await this.ls(path)).map(f => f.dir ? recursiveRm(f.path) : this.rm(f.path, false)));
|
|
@@ -186,13 +187,13 @@ class S3 extends FileSystem_1.FileSystem {
|
|
|
186
187
|
}
|
|
187
188
|
async cp(from, to, recursive) {
|
|
188
189
|
if (recursive) {
|
|
189
|
-
await Promise.all((await this.ls(from)).map(f => this.cp(f.path, (0,
|
|
190
|
+
await Promise.all((await this.ls(from)).map(f => this.cp(f.path, (0, posix_1.resolve)(to, f.name), f.dir)));
|
|
190
191
|
}
|
|
191
192
|
else {
|
|
192
193
|
const parts = (0, path_1.split)(from);
|
|
193
194
|
await this.connection.send(new client_s3_1.CopyObjectCommand({
|
|
194
195
|
Bucket: parts[0],
|
|
195
|
-
CopySource: (0,
|
|
196
|
+
CopySource: (0, posix_1.resolve)(from) + (recursive ? '/' : ''),
|
|
196
197
|
Key: (0, path_1.split)(to).slice(1).join('/') + (recursive ? '/' : '')
|
|
197
198
|
}));
|
|
198
199
|
}
|
|
@@ -213,7 +214,7 @@ class S3 extends FileSystem_1.FileSystem {
|
|
|
213
214
|
async listBuckets() {
|
|
214
215
|
const output = await this.connection.send(new client_s3_1.ListBucketsCommand({}));
|
|
215
216
|
return (output.Buckets ?? []).map(bucket => ({
|
|
216
|
-
path: (0,
|
|
217
|
+
path: (0, posix_1.join)('/', bucket.Name),
|
|
217
218
|
name: bucket.Name,
|
|
218
219
|
dir: true,
|
|
219
220
|
size: 0,
|
package/dist/fs/SFtp.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ATTRIBUTES = void 0;
|
|
4
|
-
const
|
|
4
|
+
const posix_1 = require("node:path/posix");
|
|
5
5
|
const ssh2_1 = require("ssh2");
|
|
6
6
|
const FileSystem_1 = require("../FileSystem");
|
|
7
|
+
const Local_1 = require("../Local");
|
|
7
8
|
// https://github.com/mscdex/ssh2/blob/master/SFTP.md
|
|
8
9
|
// https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13#section-4.3
|
|
9
10
|
// see also https://github.com/theophilusx/ssh2-sftp-client
|
|
@@ -107,13 +108,13 @@ class SFtp extends FileSystem_1.FileSystem {
|
|
|
107
108
|
const files = [];
|
|
108
109
|
for (let f of list) {
|
|
109
110
|
if (f.attrs.isSymbolicLink()) {
|
|
110
|
-
let target = await this.readlink((0,
|
|
111
|
-
if (!(0,
|
|
112
|
-
target = (0,
|
|
111
|
+
let target = await this.readlink((0, posix_1.join)(dir, f.filename));
|
|
112
|
+
if (!(0, posix_1.isAbsolute)(target)) {
|
|
113
|
+
target = (0, posix_1.normalize)((0, posix_1.join)(dir, target));
|
|
113
114
|
}
|
|
114
115
|
const targetStat = await this.stat(target);
|
|
115
116
|
files.push({
|
|
116
|
-
path: (0,
|
|
117
|
+
path: (0, posix_1.join)(dir, f.filename),
|
|
117
118
|
name: f.filename,
|
|
118
119
|
dir: f.attrs.isDirectory(),
|
|
119
120
|
size: targetStat.size,
|
|
@@ -126,7 +127,7 @@ class SFtp extends FileSystem_1.FileSystem {
|
|
|
126
127
|
}
|
|
127
128
|
else {
|
|
128
129
|
files.push({
|
|
129
|
-
path: (0,
|
|
130
|
+
path: (0, posix_1.join)(dir, f.filename),
|
|
130
131
|
name: f.filename,
|
|
131
132
|
dir: f.attrs.isDirectory(),
|
|
132
133
|
size: f.attrs.size,
|
|
@@ -156,13 +157,13 @@ class SFtp extends FileSystem_1.FileSystem {
|
|
|
156
157
|
async get(fromRemote, toLocal) {
|
|
157
158
|
const sftp = await this.open();
|
|
158
159
|
return new Promise((resolve, reject) => {
|
|
159
|
-
sftp.fastGet(fromRemote, toLocal, (e) => e ? reject(new Error(this.decodeError(e))) : resolve());
|
|
160
|
+
sftp.fastGet(fromRemote, (0, Local_1.osify)(toLocal), (e) => e ? reject(new Error(this.decodeError(e))) : resolve());
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
163
|
async put(fromLocal, toRemote) {
|
|
163
164
|
const sftp = await this.open();
|
|
164
165
|
return new Promise((resolve, reject) => {
|
|
165
|
-
sftp.fastPut(fromLocal, toRemote, e => e ? reject(new Error(this.decodeError(e) + ` ${toRemote}`)) : resolve());
|
|
166
|
+
sftp.fastPut((0, Local_1.osify)(fromLocal), toRemote, e => e ? reject(new Error(this.decodeError(e) + ` ${toRemote}`)) : resolve());
|
|
166
167
|
});
|
|
167
168
|
}
|
|
168
169
|
async rm(path, recursive) {
|
|
@@ -196,7 +197,7 @@ class SFtp extends FileSystem_1.FileSystem {
|
|
|
196
197
|
}
|
|
197
198
|
async mv(from, to) {
|
|
198
199
|
await this.exec(`rm -Rf '${to}'`);
|
|
199
|
-
await this.exec(`mkdir -p '${(0,
|
|
200
|
+
await this.exec(`mkdir -p '${(0, posix_1.dirname)(to)}'`);
|
|
200
201
|
return this.exec(`mv -f '${from}' '${to}'`);
|
|
201
202
|
}
|
|
202
203
|
async cp(from, to, recursive) {
|
|
@@ -204,7 +205,7 @@ class SFtp extends FileSystem_1.FileSystem {
|
|
|
204
205
|
if (recursive) {
|
|
205
206
|
return this.exec(`cp -fR '${from}' '${to}'`);
|
|
206
207
|
}
|
|
207
|
-
await this.exec(`mkdir -p '${(0,
|
|
208
|
+
await this.exec(`mkdir -p '${(0, posix_1.dirname)(to)}'`);
|
|
208
209
|
return this.exec(`cp -f '${from}' '${to}'`);
|
|
209
210
|
}
|
|
210
211
|
async write(path, s) {
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const express_1 = __importDefault(require("express"));
|
|
8
8
|
const multer_1 = __importDefault(require("multer"));
|
|
9
|
-
const
|
|
9
|
+
const posix_1 = require("node:path/posix");
|
|
10
10
|
const node_os_1 = require("node:os");
|
|
11
|
-
const
|
|
11
|
+
const Local_1 = require("./Local");
|
|
12
12
|
const App_1 = __importDefault(require("./App"));
|
|
13
13
|
const ws_1 = require("ws");
|
|
14
14
|
const open = import("open");
|
|
@@ -35,8 +35,8 @@ app.use(function (req, res, next) {
|
|
|
35
35
|
next();
|
|
36
36
|
});
|
|
37
37
|
app.use(express_1.default.json());
|
|
38
|
-
app.use(express_1.default.static((0,
|
|
39
|
-
app.use(express_1.default.static((0,
|
|
38
|
+
app.use(express_1.default.static((0, posix_1.resolve)(__dirname, 'public')));
|
|
39
|
+
app.use(express_1.default.static((0, posix_1.resolve)(__dirname, '../dist/public')));
|
|
40
40
|
const server = app.listen(port, async () => {
|
|
41
41
|
console.log(`FileFive is up on http://localhost:${port}`);
|
|
42
42
|
if (process.env.NODE_ENV !== 'development') {
|
|
@@ -60,12 +60,13 @@ const upload = (0, multer_1.default)({ dest: (0, node_os_1.tmpdir)() });
|
|
|
60
60
|
app.post('/api/upload', upload.array('files'), async function (req, res) {
|
|
61
61
|
if (Array.isArray(req.files)) {
|
|
62
62
|
const src = [];
|
|
63
|
-
for (const { path, originalname } of req.files) {
|
|
64
|
-
const
|
|
65
|
-
|
|
63
|
+
for (const { path: osPath, originalname } of req.files) {
|
|
64
|
+
const path = (0, Local_1.unosify)(osPath);
|
|
65
|
+
const fnm = (0, posix_1.join)((0, posix_1.dirname)(path), originalname);
|
|
66
|
+
await (0, Local_1.move)(path, fnm);
|
|
66
67
|
src.push(fnm);
|
|
67
68
|
}
|
|
68
|
-
commands_1.commands.copy(src.map(path => (0, URI_1.createURI)(types_1.LocalFileSystemID, path)), req.body['to'], true, null, null, null, () => src.forEach(path => (0,
|
|
69
|
+
commands_1.commands.copy(src.map(path => (0, URI_1.createURI)(types_1.LocalFileSystemID, path)), req.body['to'], true, null, null, null, () => src.forEach(path => (0, Local_1.del)(path)));
|
|
69
70
|
}
|
|
70
71
|
res.json(true);
|
|
71
72
|
});
|