hfs 0.45.0-alpha6 → 0.45.0-beta10
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 +1 -1
- package/admin/assets/{index-6c8d0372.js → index-101f19c9.js} +91 -91
- package/admin/assets/{sha512-beb2ef44.js → sha512-c0389c0d.js} +1 -1
- package/admin/index.html +1 -1
- package/frontend/assets/{index-81e42239.js → index-103f8869.js} +20 -20
- package/frontend/assets/{sha512-eec686c3.js → sha512-d8147f4f.js} +1 -1
- package/frontend/index.html +1 -1
- package/package.json +4 -4
- package/src/QuickZipStream.js +11 -6
- package/src/api.auth.js +1 -1
- package/src/commands.js +2 -4
- package/src/config.js +78 -52
- package/src/const.js +2 -3
- package/src/index.js +1 -1
- package/src/langs/embedded.js +2 -1
- package/src/langs/hfs-lang-fr.json +41 -41
- package/src/langs/hfs-lang-it.json +3 -1
- package/src/langs/hfs-lang-pt.json +109 -0
- package/src/listen.js +1 -1
- package/src/log.js +1 -1
- package/src/middlewares.js +38 -6
- package/src/perm.js +1 -1
- package/src/upload.js +2 -0
- package/src/zip.js +8 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as SF}from"./index-
|
|
1
|
+
import{c as SF}from"./index-103f8869.js";function OF(iF,hF){for(var eF=0;eF<hF.length;eF++){const tF=hF[eF];if(typeof tF!="string"&&!Array.isArray(tF)){for(const w in tF)if(w!=="default"&&!(w in iF)){const lF=Object.getOwnPropertyDescriptor(tF,w);lF&&Object.defineProperty(iF,w,lF.get?lF:{enumerable:!0,get:()=>tF[w]})}}}return Object.freeze(Object.defineProperty(iF,Symbol.toStringTag,{value:"Module"}))}var EF={},UF={get exports(){return EF},set exports(iF){EF=iF}};/*
|
|
2
2
|
* [js-sha512]{@link https://github.com/emn178/js-sha512}
|
|
3
3
|
*
|
|
4
4
|
* @version 0.8.0
|
package/frontend/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<link href="/fontello.css" rel="stylesheet" />
|
|
7
7
|
|
|
8
8
|
<script>HFS={}</script>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-103f8869.js"></script>
|
|
10
10
|
<link rel="stylesheet" href="/assets/index-fe0f3d77.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hfs",
|
|
3
|
-
"version": "0.45.0-
|
|
3
|
+
"version": "0.45.0-beta10",
|
|
4
4
|
"description": "HTTP File Server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file server",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"test": "mocha -r ts-node/register 'tests/**/*.ts'",
|
|
25
25
|
"pub": "cd dist && npm publish",
|
|
26
26
|
"dist": "npm run build-all && npm run dist-bin",
|
|
27
|
-
"dist-bin": "npm run dist-modules && cd dist && pkg . -C gzip && mv -f hfs-win-x64.exe hfs.exe && zip hfs-windows.zip hfs.exe -r plugins && cp -f hfs-linux-x64 hfs && zip hfs-linux.zip hfs -r plugins && cp -f hfs-macos-x64 hfs && zip hfs-mac.zip hfs -r plugins && cp -f hfs-macos-arm64 hfs && zip hfs-mac-arm.zip hfs -r plugins && rm hfs",
|
|
27
|
+
"dist-bin": "npm run dist-modules && cd dist && pkg . --public -C gzip && mv -f hfs-win-x64.exe hfs.exe && zip hfs-windows.zip hfs.exe -r plugins && cp -f hfs-linux-x64 hfs && zip hfs-linux.zip hfs -r plugins && cp -f hfs-macos-x64 hfs && zip hfs-mac.zip hfs -r plugins && cp -f hfs-macos-arm64 hfs && zip hfs-mac-arm.zip hfs -r plugins && rm hfs",
|
|
28
28
|
"dist-modules": "cp package*.json dist && cd dist && npm ci --omit=dev && npm run dist-crclib && rm package-lock.json && cd .. && node prune_modules",
|
|
29
29
|
"dist-crclib": "npm i -f --no-save --omit=dev @node-rs/crc32-win32-x64-msvc @node-rs/crc32-darwin-arm64 @node-rs/crc32-darwin-x64 ",
|
|
30
|
-
"dist-win": "cp package*.json dist && cd dist && npm ci --omit=dev && npm i -f --no-save --omit=dev @node-rs/crc32-win32 && pkg . -C gzip -t node16-win-x64",
|
|
31
|
-
"dist-mac": "cp package*.json dist && cd dist && npm ci --omit=dev && pkg . -C gzip -t node16-macos-arm64",
|
|
30
|
+
"dist-win": "cp package*.json dist && cd dist && npm ci --omit=dev && npm i -f --no-save --omit=dev @node-rs/crc32-win32 && pkg . --public -C gzip -t node16-win-x64",
|
|
31
|
+
"dist-mac": "cp package*.json dist && cd dist && npm ci --omit=dev && pkg . --public -C gzip -t node16-macos-arm64",
|
|
32
32
|
"dist-node": "npm run dist-modules && cd dist && zip hfs-node.zip -r * -x *.zip *.exe hfs-* *.log logs"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
package/src/QuickZipStream.js
CHANGED
|
@@ -49,6 +49,7 @@ class QuickZipStream extends stream_1.Readable {
|
|
|
49
49
|
this.dataWritten = 0;
|
|
50
50
|
this.consumedCalculating = [];
|
|
51
51
|
this.skip = 0;
|
|
52
|
+
this.now = new Date();
|
|
52
53
|
}
|
|
53
54
|
earlyClose() {
|
|
54
55
|
this.finished = true;
|
|
@@ -95,9 +96,10 @@ class QuickZipStream extends stream_1.Readable {
|
|
|
95
96
|
let centralDirSize = 0;
|
|
96
97
|
for (const file of this.consumedCalculating) {
|
|
97
98
|
const pathSize = Buffer.from(file.path, 'utf8').length;
|
|
98
|
-
const
|
|
99
|
+
const { size = 0 } = file;
|
|
100
|
+
const extraLength = (size > ZIP64_SIZE_LIMIT ? 2 : 0) + (offset > ZIP64_SIZE_LIMIT ? 1 : 0);
|
|
99
101
|
const extraDataSize = extraLength && (2 + 2 + extraLength * 8);
|
|
100
|
-
offset += 4 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + pathSize +
|
|
102
|
+
offset += 4 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + pathSize + size;
|
|
101
103
|
centralDirSize += 4 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + pathSize + extraDataSize;
|
|
102
104
|
}
|
|
103
105
|
const n = this.consumedCalculating.length;
|
|
@@ -117,7 +119,7 @@ class QuickZipStream extends stream_1.Readable {
|
|
|
117
119
|
const file = this.consumedCalculating.shift() || (await this.walker.next()).value;
|
|
118
120
|
if (!file)
|
|
119
121
|
return this.closeArchive();
|
|
120
|
-
let { path, sourcePath, getData, size, ts, mode } = file;
|
|
122
|
+
let { path, sourcePath, getData, size = 0, ts = this.now, mode = 0o40775 } = file;
|
|
121
123
|
const pathAsBuffer = Buffer.from(path, 'utf8');
|
|
122
124
|
const offset = this.dataWritten;
|
|
123
125
|
const version = 20;
|
|
@@ -126,7 +128,7 @@ class QuickZipStream extends stream_1.Readable {
|
|
|
126
128
|
2, version,
|
|
127
129
|
2, FLAGS,
|
|
128
130
|
2, 0,
|
|
129
|
-
...ts2buf(ts),
|
|
131
|
+
...ts2buf(ts || this.now),
|
|
130
132
|
4, 0,
|
|
131
133
|
4, 0,
|
|
132
134
|
4, 0,
|
|
@@ -138,7 +140,7 @@ class QuickZipStream extends stream_1.Readable {
|
|
|
138
140
|
return;
|
|
139
141
|
const cache = sourcePath ? crcCache[sourcePath] : undefined;
|
|
140
142
|
const cacheHit = Number(cache === null || cache === void 0 ? void 0 : cache.ts) === Number(ts);
|
|
141
|
-
let crc = cacheHit ? cache.crc : crc32function('');
|
|
143
|
+
let crc = cacheHit ? cache.crc : getData ? crc32function('') : 0;
|
|
142
144
|
const extAttr = !mode ? 0 : (mode | 0x8000) * 0x10000; // it's like <<16 but doesn't overflow so easily
|
|
143
145
|
const entry = { size, crc, pathAsBuffer, ts, offset, version, extAttr };
|
|
144
146
|
if (this.skip >= size && cacheHit) {
|
|
@@ -148,11 +150,14 @@ class QuickZipStream extends stream_1.Readable {
|
|
|
148
150
|
setTimeout(() => this.push('')); // this "signal" works only after _read() is done
|
|
149
151
|
return;
|
|
150
152
|
}
|
|
153
|
+
if (!getData) {
|
|
154
|
+
this.entries.push(entry);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
151
157
|
const data = getData();
|
|
152
158
|
data.on('error', (err) => console.error(err));
|
|
153
159
|
data.on('end', () => {
|
|
154
160
|
this.workingFile = undefined;
|
|
155
|
-
entry.crc = crc;
|
|
156
161
|
if (sourcePath)
|
|
157
162
|
crcCache[sourcePath] = { ts, crc };
|
|
158
163
|
this.entries.push(entry);
|
package/src/api.auth.js
CHANGED
|
@@ -32,7 +32,7 @@ async function loggedIn(ctx, username) {
|
|
|
32
32
|
}
|
|
33
33
|
function makeExp() {
|
|
34
34
|
return !keepSessionAlive.get() ? undefined
|
|
35
|
-
: { exp: new Date(Date.now() +
|
|
35
|
+
: { exp: new Date(Date.now() + middlewares_1.sessionDuration.compiled()) };
|
|
36
36
|
}
|
|
37
37
|
const login = async ({ username, password }, ctx) => {
|
|
38
38
|
if (!username || !password) // some validation
|
package/src/commands.js
CHANGED
|
@@ -79,8 +79,7 @@ const commands = {
|
|
|
79
79
|
config: {
|
|
80
80
|
params: '<key> <value>',
|
|
81
81
|
cb(key, value) {
|
|
82
|
-
|
|
83
|
-
if (!conf)
|
|
82
|
+
if (!(0, config_1.configKeyExists)(key))
|
|
84
83
|
throw "specified key doesn't exist";
|
|
85
84
|
let v = value;
|
|
86
85
|
try {
|
|
@@ -93,8 +92,7 @@ const commands = {
|
|
|
93
92
|
'get-config': {
|
|
94
93
|
params: '<key>',
|
|
95
94
|
cb(key) {
|
|
96
|
-
|
|
97
|
-
if (!conf)
|
|
95
|
+
if (!(0, config_1.configKeyExists)(key))
|
|
98
96
|
throw "specified key doesn't exist";
|
|
99
97
|
console.log(yaml_1.default.stringify((0, config_1.getConfig)(key), { lineWidth: 1000 }).trim());
|
|
100
98
|
}
|
package/src/config.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.saveConfigAsap = exports.setConfig = exports.getWholeConfig = exports.getConfig = exports.
|
|
7
|
+
exports.saveConfigAsap = exports.setConfig = exports.getWholeConfig = exports.getConfig = exports.configKeyExists = exports.defineConfig = void 0;
|
|
8
8
|
const events_1 = __importDefault(require("events"));
|
|
9
9
|
const const_1 = require("./const");
|
|
10
10
|
const watchLoad_1 = require("./watchLoad");
|
|
@@ -15,12 +15,13 @@ const fs_1 = require("fs");
|
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const events_2 = __importDefault(require("./events"));
|
|
17
17
|
const FILE = 'config.yaml';
|
|
18
|
+
// keep definition of config properties
|
|
18
19
|
const configProps = {};
|
|
19
20
|
let started = false; // this will tell the difference for subscribeConfig()s that are called before or after config is loaded
|
|
20
|
-
let state = {};
|
|
21
|
+
let state = {}; // current state of config properties
|
|
21
22
|
const cfgEvents = new events_1.default();
|
|
22
23
|
cfgEvents.setMaxListeners(10000);
|
|
23
|
-
const
|
|
24
|
+
const filePath = (0, misc_1.with_)(const_1.argv.config || process.env.HFS_CONFIG, p => {
|
|
24
25
|
if (!p)
|
|
25
26
|
return FILE;
|
|
26
27
|
p = (0, path_1.resolve)(const_1.ORIGINAL_CWD, p);
|
|
@@ -31,32 +32,49 @@ const path = (0, misc_1.with_)(const_1.argv.config || process.env.HFS_CONFIG, p
|
|
|
31
32
|
catch (_a) { }
|
|
32
33
|
return p;
|
|
33
34
|
});
|
|
34
|
-
console.log("config",
|
|
35
|
+
console.log("config", filePath);
|
|
35
36
|
const legacyPosition = (0, path_1.join)(const_1.APP_PATH, FILE);
|
|
36
|
-
if (!(0, fs_1.existsSync)(
|
|
37
|
+
if (!(0, fs_1.existsSync)(filePath) && (0, fs_1.existsSync)(legacyPosition))
|
|
37
38
|
try {
|
|
38
|
-
(0, fs_1.renameSync)(legacyPosition,
|
|
39
|
+
(0, fs_1.renameSync)(legacyPosition, filePath);
|
|
39
40
|
console.log("moved from legacy position", legacyPosition);
|
|
40
41
|
}
|
|
41
42
|
catch (_a) {
|
|
42
43
|
try { // attempt copying, in case moving the source file proves to be impractical
|
|
43
|
-
(0, fs_1.copyFileSync)(legacyPosition,
|
|
44
|
+
(0, fs_1.copyFileSync)(legacyPosition, filePath);
|
|
44
45
|
console.log("copied from legacy position", legacyPosition);
|
|
45
46
|
}
|
|
46
47
|
catch (_b) { }
|
|
47
48
|
}
|
|
48
|
-
const { save } = (0, watchLoad_1.watchLoad)(
|
|
49
|
+
const { save } = (0, watchLoad_1.watchLoad)(filePath, text => setConfig(yaml_1.default.parse(text) || {}, false), {
|
|
49
50
|
failedOnFirstAttempt() {
|
|
50
51
|
console.log("No config file, using defaults");
|
|
51
52
|
setConfig({}, false);
|
|
52
53
|
}
|
|
53
54
|
});
|
|
54
|
-
|
|
55
|
+
// takes a semver like 1.2.3-alpha1, but alpha and beta numbers must share the number progression
|
|
56
|
+
const versionToScalar = lodash_1.default.memoize((ver) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const [official, beta] = ver.split('-');
|
|
59
|
+
const numbers = official.split('.').map(Number);
|
|
60
|
+
if (numbers.length !== 3)
|
|
61
|
+
return NaN;
|
|
62
|
+
const officialScalar = numbers.reduce((acc, x, i) => acc + x * 1000 ** (2 - i), 0); // 1000 gives 3 digits for each number
|
|
63
|
+
const betaScalar = 1 / (beta && Number((_a = /\d+/.exec(beta)) === null || _a === void 0 ? void 0 : _a[0]) || Infinity); // beta tends to 0, while non-beta is 0
|
|
64
|
+
return officialScalar - betaScalar;
|
|
65
|
+
});
|
|
66
|
+
class Version extends String {
|
|
67
|
+
olderThan(otherVersion) {
|
|
68
|
+
return versionToScalar(this.valueOf()) < versionToScalar(otherVersion);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const CONFIG_CHANGE_EVENT_PREFIX = 'new.';
|
|
72
|
+
const currentVersion = new Version(const_1.VERSION);
|
|
73
|
+
const configVersion = defineConfig('version', const_1.VERSION, v => new Version(v));
|
|
74
|
+
function defineConfig(k, defaultValue, compiler) {
|
|
55
75
|
configProps[k] = { defaultValue };
|
|
56
|
-
let compiled = compiler(defaultValue);
|
|
57
|
-
|
|
58
|
-
subscribeConfig(k, (v) => compiled = compiler(v));
|
|
59
|
-
return {
|
|
76
|
+
let compiled = compiler === null || compiler === void 0 ? void 0 : compiler(defaultValue, undefined, currentVersion);
|
|
77
|
+
const ret = {
|
|
60
78
|
key() {
|
|
61
79
|
return k;
|
|
62
80
|
},
|
|
@@ -64,7 +82,22 @@ function defineConfig(k, defaultValue, compiler = lodash_1.default.identity) {
|
|
|
64
82
|
return getConfig(k);
|
|
65
83
|
},
|
|
66
84
|
sub(cb) {
|
|
67
|
-
|
|
85
|
+
if (started) // initial event already passed, we'll make the first call
|
|
86
|
+
cb(getConfig(k), defaultValue, configVersion.compiled());
|
|
87
|
+
const eventName = CONFIG_CHANGE_EVENT_PREFIX + k;
|
|
88
|
+
return (0, misc_1.onOff)(cfgEvents, {
|
|
89
|
+
[eventName]() {
|
|
90
|
+
if (stack.includes(cb))
|
|
91
|
+
return; // avoid infinite loop in case a subscriber changes the value
|
|
92
|
+
stack.push(cb); // @ts-ignore arguments
|
|
93
|
+
try {
|
|
94
|
+
return cb.apply(this, arguments);
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
stack.pop();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
68
101
|
},
|
|
69
102
|
set(v) {
|
|
70
103
|
if (typeof v === 'function')
|
|
@@ -72,33 +105,22 @@ function defineConfig(k, defaultValue, compiler = lodash_1.default.identity) {
|
|
|
72
105
|
else
|
|
73
106
|
setConfig1(k, v);
|
|
74
107
|
},
|
|
75
|
-
compiled: () =>
|
|
108
|
+
compiled: () => {
|
|
109
|
+
if (!compiler)
|
|
110
|
+
throw "missing compiler";
|
|
111
|
+
return compiled;
|
|
112
|
+
}
|
|
76
113
|
};
|
|
114
|
+
if (compiler)
|
|
115
|
+
ret.sub((...args) => compiled = compiler(...args));
|
|
116
|
+
return ret;
|
|
77
117
|
}
|
|
78
118
|
exports.defineConfig = defineConfig;
|
|
79
|
-
function
|
|
80
|
-
return configProps
|
|
119
|
+
function configKeyExists(k) {
|
|
120
|
+
return k in configProps;
|
|
81
121
|
}
|
|
82
|
-
exports.
|
|
122
|
+
exports.configKeyExists = configKeyExists;
|
|
83
123
|
const stack = [];
|
|
84
|
-
function subscribeConfig(k, cb) {
|
|
85
|
-
if (started) // initial event already passed, we'll make the first call
|
|
86
|
-
cb(getConfig(k));
|
|
87
|
-
const eventName = 'new.' + k;
|
|
88
|
-
return (0, misc_1.onOff)(cfgEvents, {
|
|
89
|
-
[eventName]() {
|
|
90
|
-
if (stack.includes(cb))
|
|
91
|
-
return; // avoid infinite loop in case a subscriber changes the value
|
|
92
|
-
stack.push(cb); // @ts-ignore arguments
|
|
93
|
-
try {
|
|
94
|
-
return cb.apply(this, arguments);
|
|
95
|
-
}
|
|
96
|
-
finally {
|
|
97
|
-
stack.pop();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
124
|
function getConfig(k) {
|
|
103
125
|
var _a, _b;
|
|
104
126
|
return (_a = state[k]) !== null && _a !== void 0 ? _a : lodash_1.default.cloneDeep((_b = configProps[k]) === null || _b === void 0 ? void 0 : _b.defaultValue); // clone to avoid changing
|
|
@@ -116,17 +138,17 @@ function getWholeConfig({ omit, only }) {
|
|
|
116
138
|
exports.getWholeConfig = getWholeConfig;
|
|
117
139
|
// pass a value to `save` to force saving decision, or leave undefined for auto. Passing false will also reset previously loaded configs.
|
|
118
140
|
function setConfig(newCfg, save) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
141
|
+
const version = lodash_1.default.isString(newCfg.version) ? new Version(newCfg.version) : undefined;
|
|
142
|
+
// first time we consider also CLI args
|
|
143
|
+
const argCfg = !started && lodash_1.default.pickBy((0, misc_1.newObj)(configProps, (x, k) => const_1.argv[k]), x => x !== undefined);
|
|
144
|
+
if (!lodash_1.default.isEmpty(argCfg)) {
|
|
145
|
+
(0, exports.saveConfigAsap)(); // don't set `save` argument, as it would interfere below at check `save===false`
|
|
146
|
+
Object.assign(newCfg, argCfg);
|
|
125
147
|
}
|
|
126
148
|
for (const k in newCfg)
|
|
127
149
|
apply(k, newCfg[k]);
|
|
128
150
|
if (save) {
|
|
129
|
-
(0, exports.saveConfigAsap)()
|
|
151
|
+
(0, exports.saveConfigAsap)();
|
|
130
152
|
return;
|
|
131
153
|
}
|
|
132
154
|
if (started) {
|
|
@@ -139,15 +161,17 @@ function setConfig(newCfg, save) {
|
|
|
139
161
|
// first time we emit also for the default values
|
|
140
162
|
for (const k of Object.keys(configProps))
|
|
141
163
|
if (!newCfg.hasOwnProperty(k))
|
|
142
|
-
apply(k, newCfg[k]);
|
|
164
|
+
apply(k, newCfg[k], true);
|
|
143
165
|
started = true;
|
|
144
166
|
events_2.default.emit('config ready');
|
|
145
|
-
|
|
146
|
-
|
|
167
|
+
if (version !== const_1.VERSION) // be sure to save version
|
|
168
|
+
(0, exports.saveConfigAsap)();
|
|
169
|
+
function apply(k, newV, isDefault = false) {
|
|
170
|
+
return setConfig1(k, newV, save === undefined, argCfg && k in argCfg || isDefault ? currentVersion : version);
|
|
147
171
|
}
|
|
148
172
|
}
|
|
149
173
|
exports.setConfig = setConfig;
|
|
150
|
-
function setConfig1(k, newV, saveChanges = true) {
|
|
174
|
+
function setConfig1(k, newV, saveChanges = true, valueVersion) {
|
|
151
175
|
var _a;
|
|
152
176
|
if (lodash_1.default.isPlainObject(newV))
|
|
153
177
|
newV = lodash_1.default.pickBy(newV, x => x !== undefined);
|
|
@@ -158,16 +182,18 @@ function setConfig1(k, newV, saveChanges = true) {
|
|
|
158
182
|
return; // no change
|
|
159
183
|
const was = getConfig(k); // include cloned default, if necessary
|
|
160
184
|
state[k] = newV;
|
|
161
|
-
cfgEvents.emit(
|
|
185
|
+
cfgEvents.emit(CONFIG_CHANGE_EVENT_PREFIX + k, getConfig(k), was, valueVersion);
|
|
162
186
|
if (saveChanges)
|
|
163
|
-
(0, exports.saveConfigAsap)()
|
|
187
|
+
(0, exports.saveConfigAsap)();
|
|
164
188
|
}
|
|
165
|
-
|
|
189
|
+
const saveDebounced = (0, misc_1.debounceAsync)(async () => {
|
|
166
190
|
while (!started)
|
|
167
191
|
await (0, misc_1.wait)(100);
|
|
168
|
-
let txt = yaml_1.default.stringify(state, { lineWidth: 1000 });
|
|
192
|
+
let txt = yaml_1.default.stringify({ version: const_1.VERSION, ...state }, { lineWidth: 1000 });
|
|
169
193
|
if (txt.trim() === '{}') // most users wouldn't understand
|
|
170
194
|
txt = '';
|
|
171
|
-
save(
|
|
195
|
+
save(filePath, txt)
|
|
172
196
|
.catch(err => console.error('Failed at saving config file, please ensure it is writable.', String(err)));
|
|
173
197
|
});
|
|
198
|
+
const saveConfigAsap = () => void (saveDebounced());
|
|
199
|
+
exports.saveConfigAsap = saveConfigAsap;
|
package/src/const.js
CHANGED
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.APP_PATH = exports.IS_BINARY = exports.IS_WINDOWS = exports.HTTP_SERVER_ERROR = exports.HTTP_FOOL = exports.HTTP_RANGE_NOT_SATISFIABLE = exports.HTTP_PAYLOAD_TOO_LARGE = exports.HTTP_CONFLICT = exports.HTTP_NOT_ACCEPTABLE = exports.HTTP_METHOD_NOT_ALLOWED = exports.HTTP_NOT_FOUND = exports.HTTP_FORBIDDEN = exports.HTTP_UNAUTHORIZED = exports.HTTP_BAD_REQUEST = exports.HTTP_NOT_MODIFIED = exports.HTTP_TEMPORARY_REDIRECT = exports.HTTP_PARTIAL_CONTENT = exports.HTTP_NO_CONTENT = exports.HTTP_OK = exports.PLUGINS_PUB_URI = exports.API_URI = exports.ADMIN_URI = exports.FRONTEND_URI = exports.SPECIAL_URI = exports.HFS_REPO = exports.COMPATIBLE_API_VERSION = exports.API_VERSION = exports.
|
|
30
|
+
exports.APP_PATH = exports.IS_BINARY = exports.IS_WINDOWS = exports.HTTP_SERVER_ERROR = exports.HTTP_FOOL = exports.HTTP_RANGE_NOT_SATISFIABLE = exports.HTTP_PAYLOAD_TOO_LARGE = exports.HTTP_CONFLICT = exports.HTTP_NOT_ACCEPTABLE = exports.HTTP_METHOD_NOT_ALLOWED = exports.HTTP_NOT_FOUND = exports.HTTP_FORBIDDEN = exports.HTTP_UNAUTHORIZED = exports.HTTP_BAD_REQUEST = exports.HTTP_NOT_MODIFIED = exports.HTTP_TEMPORARY_REDIRECT = exports.HTTP_PARTIAL_CONTENT = exports.HTTP_NO_CONTENT = exports.HTTP_OK = exports.PLUGINS_PUB_URI = exports.API_URI = exports.ADMIN_URI = exports.FRONTEND_URI = exports.SPECIAL_URI = exports.HFS_REPO = exports.COMPATIBLE_API_VERSION = exports.API_VERSION = exports.DAY = exports.VERSION = exports.BUILD_TIMESTAMP = exports.HFS_STARTED = exports.ORIGINAL_CWD = exports.DEV = exports.argv = void 0;
|
|
31
31
|
const minimist_1 = __importDefault(require("minimist"));
|
|
32
32
|
const fs = __importStar(require("fs"));
|
|
33
33
|
const os_1 = require("os");
|
|
@@ -38,11 +38,10 @@ exports.DEV = process.env.DEV || exports.argv.dev ? 'DEV' : '';
|
|
|
38
38
|
exports.ORIGINAL_CWD = process.cwd();
|
|
39
39
|
exports.HFS_STARTED = new Date();
|
|
40
40
|
const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
|
|
41
|
-
exports.BUILD_TIMESTAMP = "2023-05-
|
|
41
|
+
exports.BUILD_TIMESTAMP = "2023-05-16T09:05:52.263Z";
|
|
42
42
|
const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
|
|
43
43
|
exports.VERSION = pkg.version;
|
|
44
44
|
exports.DAY = 86400000;
|
|
45
|
-
exports.SESSION_DURATION = Number(process.env.SESSION_DURATION) * 1000 || exports.DAY;
|
|
46
45
|
exports.API_VERSION = 8.1; // entry.uri + script.plugin + absolute frontend_*
|
|
47
46
|
exports.COMPATIBLE_API_VERSION = 1; // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
|
|
48
47
|
exports.HFS_REPO = 'rejetto/hfs';
|
package/src/index.js
CHANGED
|
@@ -28,7 +28,7 @@ const koa_session_1 = __importDefault(require("koa-session"));
|
|
|
28
28
|
const keys = ((_a = process.env.COOKIE_SIGN_KEYS) === null || _a === void 0 ? void 0 : _a.split(',')) || [(0, misc_1.randomId)(30)];
|
|
29
29
|
exports.app = new koa_1.default({ keys });
|
|
30
30
|
exports.app.use(middlewares_1.someSecurity)
|
|
31
|
-
.use((0, koa_session_1.default)({ key: 'hfs_$id', signed: true, rolling: true
|
|
31
|
+
.use((0, koa_session_1.default)({ key: 'hfs_$id', signed: true, rolling: true }, exports.app))
|
|
32
32
|
.use(middlewares_1.prepareState)
|
|
33
33
|
.use(middlewares_1.headRequests)
|
|
34
34
|
.use((0, log_1.log)())
|
package/src/langs/embedded.js
CHANGED
|
@@ -11,4 +11,5 @@ const hfs_lang_ko_json_1 = __importDefault(require("./hfs-lang-ko.json"));
|
|
|
11
11
|
const hfs_lang_ms_json_1 = __importDefault(require("./hfs-lang-ms.json"));
|
|
12
12
|
const hfs_lang_zh_tw_json_1 = __importDefault(require("./hfs-lang-zh-tw.json"));
|
|
13
13
|
const hfs_lang_fr_json_1 = __importDefault(require("./hfs-lang-fr.json"));
|
|
14
|
-
|
|
14
|
+
const hfs_lang_pt_json_1 = __importDefault(require("./hfs-lang-pt.json"));
|
|
15
|
+
exports.default = { it: hfs_lang_it_json_1.default, zh: hfs_lang_zh_json_1.default, ru: hfs_lang_ru_json_1.default, sr: hfs_lang_sr_json_1.default, ko: hfs_lang_ko_json_1.default, ms: hfs_lang_ms_json_1.default, 'zh-tw': hfs_lang_zh_tw_json_1.default, fr: hfs_lang_fr_json_1.default, pt: hfs_lang_pt_json_1.default };
|
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Club Microtel Vernon",
|
|
3
|
-
"version": 1.
|
|
3
|
+
"version": 1.1,
|
|
4
4
|
"hfs_version": "0.43.0",
|
|
5
5
|
"translate": {
|
|
6
6
|
"Select": "Selectionner",
|
|
7
7
|
"n_files": "{n,plural, one{# fichier} other{# fichiers}}",
|
|
8
8
|
"n_folders": "{n,plural, one{# dossier} other{# dossiers}}",
|
|
9
|
-
"filter_count": "{n,plural, one{#
|
|
10
|
-
"select_count": "{n,plural, one{#
|
|
9
|
+
"filter_count": "{n,plural, one{# filtré ;} other{# filtrés}}",
|
|
10
|
+
"select_count": "{n,plural, one{# selectionné} other{# selectionnés}}",
|
|
11
11
|
"filter_placeholder": "Saisissez ici pour filtrer la liste ci-dessous",
|
|
12
|
-
"Select some files": "
|
|
13
|
-
"zip_checkboxes": "Utilisez les cases
|
|
14
|
-
"zip_tooltip_selected": "
|
|
15
|
-
"zip_tooltip_whole": "
|
|
16
|
-
"zip_confirm_search": "
|
|
17
|
-
"zip_confirm_folder": "
|
|
18
|
-
"select_tooltip": "La
|
|
19
|
-
"delete_hint": "Pour supprimer, cliquez en premier sur
|
|
20
|
-
"delete_confirm": "Supprimer {n,plural, one{#
|
|
21
|
-
"delete_completed": "Suppression: {n}
|
|
22
|
-
"delete_failed": "
|
|
23
|
-
"delete_select": "
|
|
12
|
+
"Select some files": "Sélectionnez des fichiers",
|
|
13
|
+
"zip_checkboxes": "Utilisez les cases à cocher pour sélectionner les fichiers, vous pourrez alors utiliser ZIP à nouveau",
|
|
14
|
+
"zip_tooltip_selected": "Télécharger les éléments sélectionnés dans un seul fichier compressé (.zip)",
|
|
15
|
+
"zip_tooltip_whole": "Téléchargez la liste complète (non filtrée) sous la forme d'un seul fichier compressé (.zip). Si vous sélectionnez certains éléments, seuls ceux-ci seront téléchargés",
|
|
16
|
+
"zip_confirm_search": "Télécharger le résultat de la recherche dans un fichier compressé (.zip)?",
|
|
17
|
+
"zip_confirm_folder": "Télécharger le dossier COMPLET compressé (.zip)?",
|
|
18
|
+
"select_tooltip": "La sélection influe sur le comportement des boutons [ZIP] et [Supprimer] quand disponibles, mais vous pouvez aussi filtrer la liste",
|
|
19
|
+
"delete_hint": "Pour supprimer, cliquez en premier sur sélectionner",
|
|
20
|
+
"delete_confirm": "Supprimer {n,plural, one{# élément} other{# éléments}}?",
|
|
21
|
+
"delete_completed": "Suppression: {n} terminé(s)",
|
|
22
|
+
"delete_failed": "{n,plural, one{# en échec} other{# en échec}}",
|
|
23
|
+
"delete_select": "Sélectionnez un ou plusieurs élément(s) à supprimer",
|
|
24
24
|
"Delete": "Supprimer",
|
|
25
25
|
"Options": "Options",
|
|
26
26
|
"Search": "Recherche",
|
|
27
27
|
"Zip": "ZIP",
|
|
28
28
|
"search_msg": "Rechercher dans ce dossier et ses sous-dossiers",
|
|
29
29
|
"Searching": "Recherche",
|
|
30
|
-
"Searched": "Recherche
|
|
30
|
+
"Searched": "Recherche terminée",
|
|
31
31
|
"Clear search": "Effacer la recherche",
|
|
32
32
|
"Interrupted": "Interrompu",
|
|
33
|
-
"stopped_before": "Chargement
|
|
33
|
+
"stopped_before": "Chargement annulé",
|
|
34
34
|
"empty_list": "Liste vide",
|
|
35
35
|
"filter_none": "Aucun filtre",
|
|
36
36
|
"Admin-panel": "Page Administration",
|
|
37
37
|
"Login": "Connexion",
|
|
38
38
|
"Username": "Utilisateur",
|
|
39
39
|
"Password": "Mot de Passe",
|
|
40
|
-
"login_untrusted": "Connexion
|
|
40
|
+
"login_untrusted": "Connexion annulée: problème de certificat du serveur",
|
|
41
41
|
"login_bad_credentials": "Identifiant ou mot de passe invalide",
|
|
42
|
-
"login_bad_cookies": "
|
|
42
|
+
"login_bad_cookies": "Problème de cookies : échec de la connexion",
|
|
43
43
|
"User panel": "Connexion Utilisateur",
|
|
44
44
|
"Change password": "Changer le mot de passe",
|
|
45
45
|
"enter_pass": "Entrez un nouveau mot de passe",
|
|
46
46
|
"enter_pass2": "Confirmez le nouveau mot de passe",
|
|
47
|
-
"pass2_mismatch": "Le second mot de passe ne correspond pas au premier :
|
|
48
|
-
"password_changed": "Mot de passe
|
|
49
|
-
"Logout": "
|
|
47
|
+
"pass2_mismatch": "Le second mot de passe ne correspond pas au premier : échec de la connexion",
|
|
48
|
+
"password_changed": "Mot de passe modifié",
|
|
49
|
+
"Logout": "Déconnexion",
|
|
50
50
|
"connection error": "Erreur de connexion",
|
|
51
51
|
"Full timestamp:": "Horodatage complet:",
|
|
52
52
|
"Search was interrupted": "Recherche interrompue",
|
|
53
|
-
"Stop list": "
|
|
54
|
-
"upload_starting": "Votre
|
|
55
|
-
"wrong_account": "Aucun
|
|
56
|
-
"no_upload_here": "Pas de permission de
|
|
57
|
-
"Create folder": "
|
|
53
|
+
"Stop list": "Arrêter le chargement de la liste",
|
|
54
|
+
"upload_starting": "Votre télé-chargement devrait commencer maintenant",
|
|
55
|
+
"wrong_account": "Aucun accès défini pour ce compte, essayez avec un autre compte",
|
|
56
|
+
"no_upload_here": "Pas de permission de télé-versement pour ce dossier",
|
|
57
|
+
"Create folder": "Créez un dossier",
|
|
58
58
|
"Pick files": "Choisissez les fichiers",
|
|
59
59
|
"Pick folder": "Choisissez un dossier",
|
|
60
60
|
"send_files": "Envoyer {n,plural,one{# fichier} other{# fichiers}}, {size}",
|
|
61
61
|
"Clear": "Effacer",
|
|
62
|
-
"failed_upload": "Impossible de
|
|
63
|
-
"confirm_resume": "Reprendre le
|
|
62
|
+
"failed_upload": "Impossible de transférer {name}",
|
|
63
|
+
"confirm_resume": "Reprendre le télé-versement?",
|
|
64
64
|
"file too large": "Fichier trop gros",
|
|
65
65
|
"Enter folder name": "Saisissez le nom du dossier",
|
|
66
|
-
"Successfully created": "
|
|
66
|
+
"Successfully created": "Créé avec succès",
|
|
67
67
|
"enter_folder": "Saisissez le dossier",
|
|
68
|
-
"folder_exists": "Un dossier avec le
|
|
68
|
+
"folder_exists": "Un dossier avec le même nom éxiste déjà",
|
|
69
69
|
"Sort by": "Trier par",
|
|
70
70
|
"name": "Nom",
|
|
71
71
|
"extension": "Extension",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"time": "Heure",
|
|
74
74
|
"Invert order": "Inverser le tri",
|
|
75
75
|
"Folders first": "Dossiers en premier",
|
|
76
|
-
"Numeric names": "Noms
|
|
77
|
-
"theme:": "
|
|
76
|
+
"Numeric names": "Noms numériques",
|
|
77
|
+
"theme:": "Thème:",
|
|
78
78
|
"auto": "Auto",
|
|
79
79
|
"light": "Clair",
|
|
80
80
|
"dark": "Sombre",
|
|
@@ -86,21 +86,21 @@
|
|
|
86
86
|
"Warning": "Avertissement",
|
|
87
87
|
"Error": "Erreur",
|
|
88
88
|
"Info": "Info",
|
|
89
|
-
"Unauthorized": "Non
|
|
89
|
+
"Unauthorized": "Non autorisé",
|
|
90
90
|
"Forbidden": "Interdit",
|
|
91
|
-
"Not found": "Non
|
|
91
|
+
"Not found": "Non trouvé",
|
|
92
92
|
"Server error": "Erreur du serveur",
|
|
93
93
|
"Upload": "Envoyer",
|
|
94
|
-
"upload_concluded": "Envoi termin
|
|
95
|
-
"upload_finished": "{n}
|
|
96
|
-
"upload_errors": "{n}
|
|
97
|
-
"upload_file_rejected": "Certains fichiers ont
|
|
98
|
-
"download counter": "Compteur de
|
|
94
|
+
"upload_concluded": "Envoi terminé:",
|
|
95
|
+
"upload_finished": "{n} terminé(s) ({size})",
|
|
96
|
+
"upload_errors": "{n} échoués",
|
|
97
|
+
"upload_file_rejected": "Certains fichiers ont été refusés",
|
|
98
|
+
"download counter": "Compteur de téléchargements",
|
|
99
99
|
"File menu": "Menu du fichier",
|
|
100
100
|
"Folder menu": "Menu du dossier",
|
|
101
101
|
"Name": "Nom",
|
|
102
102
|
"file_open": "Ouvrir",
|
|
103
|
-
"Download": "
|
|
103
|
+
"Download": "Télécharger",
|
|
104
104
|
"Missing permission": "Permission manquante"
|
|
105
105
|
}
|
|
106
106
|
}
|