hfs 0.26.7 → 0.26.8

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.
Files changed (162) hide show
  1. package/admin/.DS_Store +0 -0
  2. package/admin/.eslintrc +8 -0
  3. package/admin/.gitignore +23 -0
  4. package/admin/index.html +1 -3
  5. package/admin/package.json +67 -0
  6. package/admin/{logo.svg → public/logo.svg} +0 -0
  7. package/admin/src/AccountForm.ts +92 -0
  8. package/admin/src/AccountsPage.ts +143 -0
  9. package/admin/src/App.ts +83 -0
  10. package/admin/src/ArrayField.ts +84 -0
  11. package/admin/src/ConfigPage.ts +279 -0
  12. package/admin/src/FileField.ts +52 -0
  13. package/admin/src/FileForm.ts +148 -0
  14. package/admin/src/FilePicker.ts +166 -0
  15. package/admin/src/HomePage.ts +96 -0
  16. package/admin/src/InstalledPlugins.ts +158 -0
  17. package/admin/src/LoginRequired.ts +75 -0
  18. package/admin/src/LogoutPage.ts +27 -0
  19. package/admin/src/LogsPage.ts +75 -0
  20. package/admin/src/MainMenu.ts +74 -0
  21. package/admin/src/MenuButton.ts +38 -0
  22. package/admin/src/MonitorPage.ts +200 -0
  23. package/admin/src/OnlinePlugins.ts +101 -0
  24. package/admin/src/PermField.ts +80 -0
  25. package/admin/src/PluginsPage.ts +27 -0
  26. package/admin/src/VfsMenuBar.ts +58 -0
  27. package/admin/src/VfsPage.ts +124 -0
  28. package/admin/src/VfsTree.ts +95 -0
  29. package/admin/src/addFiles.ts +59 -0
  30. package/admin/src/api.ts +246 -0
  31. package/admin/src/dialog.ts +203 -0
  32. package/admin/src/index.css +21 -0
  33. package/admin/src/index.ts +10 -0
  34. package/admin/src/md.ts +31 -0
  35. package/admin/src/misc.ts +141 -0
  36. package/admin/src/react-app-env.d.ts +1 -0
  37. package/admin/src/reportWebVitals.ts +15 -0
  38. package/admin/src/setupTests.ts +5 -0
  39. package/admin/src/state.ts +40 -0
  40. package/admin/src/theme.ts +37 -0
  41. package/admin/tsconfig.json +26 -0
  42. package/admin/vite.config.ts +32 -0
  43. package/frontend/.DS_Store +0 -0
  44. package/frontend/.eslintrc +8 -0
  45. package/frontend/.gitignore +23 -0
  46. package/frontend/index.html +1 -3
  47. package/frontend/package.json +51 -0
  48. package/frontend/{fontello.css → public/fontello.css} +0 -0
  49. package/frontend/{fontello.woff2 → public/fontello.woff2} +0 -0
  50. package/frontend/src/App.ts +25 -0
  51. package/frontend/src/Breadcrumbs.ts +43 -0
  52. package/frontend/src/BrowseFiles.ts +141 -0
  53. package/frontend/src/Head.ts +45 -0
  54. package/frontend/src/UserPanel.ts +52 -0
  55. package/frontend/src/api.ts +78 -0
  56. package/frontend/src/components.ts +54 -0
  57. package/frontend/src/dialog.css +76 -0
  58. package/frontend/src/dialog.ts +105 -0
  59. package/frontend/src/icons.ts +46 -0
  60. package/frontend/src/index.scss +307 -0
  61. package/frontend/src/index.ts +10 -0
  62. package/frontend/src/login.ts +50 -0
  63. package/frontend/src/menu.ts +188 -0
  64. package/frontend/src/misc.ts +54 -0
  65. package/frontend/src/options.ts +52 -0
  66. package/frontend/src/react-app-env.d.ts +1 -0
  67. package/frontend/src/reportWebVitals.ts +15 -0
  68. package/frontend/src/setupTests.ts +5 -0
  69. package/frontend/src/state.ts +82 -0
  70. package/frontend/src/useAuthorized.ts +17 -0
  71. package/frontend/src/useFetchList.ts +144 -0
  72. package/frontend/src/useTheme.ts +23 -0
  73. package/frontend/tsconfig.json +26 -0
  74. package/frontend/vite.config.ts +21 -0
  75. package/package.json +2 -1
  76. package/plugins/vhosting/plugin.js +1 -1
  77. package/src/QuickZipStream.ts +279 -0
  78. package/src/ThrottledStream.ts +98 -0
  79. package/src/adminApis.ts +161 -0
  80. package/src/api.accounts.ts +78 -0
  81. package/src/api.auth.ts +131 -0
  82. package/src/api.file_list.ts +102 -0
  83. package/src/api.helpers.ts +30 -0
  84. package/src/api.monitor.ts +106 -0
  85. package/src/api.plugins.ts +139 -0
  86. package/src/api.vfs.ts +182 -0
  87. package/src/apiMiddleware.ts +124 -0
  88. package/src/block.ts +35 -0
  89. package/src/commands.ts +122 -0
  90. package/src/config.ts +166 -0
  91. package/src/connections.ts +60 -0
  92. package/src/const.ts +57 -0
  93. package/src/crypt.ts +16 -0
  94. package/src/debounceAsync.ts +51 -0
  95. package/src/events.ts +6 -0
  96. package/src/frontEndApis.ts +17 -0
  97. package/src/github.ts +102 -0
  98. package/src/index.ts +53 -0
  99. package/src/listen.ts +220 -0
  100. package/src/log.ts +128 -0
  101. package/src/middlewares.ts +176 -0
  102. package/src/misc.ts +149 -0
  103. package/src/pbkdf2.ts +83 -0
  104. package/src/perm.ts +194 -0
  105. package/src/plugins.ts +342 -0
  106. package/src/serveFile.ts +104 -0
  107. package/src/serveGuiFiles.ts +95 -0
  108. package/src/sse.ts +29 -0
  109. package/src/throttler.ts +106 -0
  110. package/src/update.ts +67 -0
  111. package/src/util-files.ts +137 -0
  112. package/src/util-generators.ts +29 -0
  113. package/src/util-http.ts +29 -0
  114. package/src/vfs.ts +258 -0
  115. package/src/watchLoad.ts +75 -0
  116. package/src/zip.ts +69 -0
  117. package/admin/assets/index.0f549e00.js +0 -281
  118. package/admin/assets/index.dcc78777.css +0 -1
  119. package/admin/assets/sha512.ea1121b3.js +0 -8
  120. package/frontend/assets/index.1151988f.js +0 -85
  121. package/frontend/assets/index.93366732.css +0 -1
  122. package/frontend/assets/sha512.bb881250.js +0 -8
  123. package/src/QuickZipStream.js +0 -285
  124. package/src/ThrottledStream.js +0 -93
  125. package/src/adminApis.js +0 -169
  126. package/src/api.accounts.js +0 -59
  127. package/src/api.auth.js +0 -130
  128. package/src/api.file_list.js +0 -103
  129. package/src/api.helpers.js +0 -32
  130. package/src/api.monitor.js +0 -102
  131. package/src/api.plugins.js +0 -127
  132. package/src/api.vfs.js +0 -164
  133. package/src/apiMiddleware.js +0 -136
  134. package/src/block.js +0 -33
  135. package/src/commands.js +0 -124
  136. package/src/config.js +0 -168
  137. package/src/connections.js +0 -57
  138. package/src/const.js +0 -83
  139. package/src/crypt.js +0 -21
  140. package/src/debounceAsync.js +0 -48
  141. package/src/events.js +0 -9
  142. package/src/frontEndApis.js +0 -38
  143. package/src/github.js +0 -102
  144. package/src/index.js +0 -55
  145. package/src/listen.js +0 -235
  146. package/src/log.js +0 -137
  147. package/src/middlewares.js +0 -154
  148. package/src/misc.js +0 -160
  149. package/src/pbkdf2.js +0 -74
  150. package/src/perm.js +0 -176
  151. package/src/plugins.js +0 -343
  152. package/src/serveFile.js +0 -104
  153. package/src/serveGuiFiles.js +0 -113
  154. package/src/sse.js +0 -29
  155. package/src/throttler.js +0 -91
  156. package/src/update.js +0 -69
  157. package/src/util-files.js +0 -148
  158. package/src/util-generators.js +0 -30
  159. package/src/util-http.js +0 -30
  160. package/src/vfs.js +0 -227
  161. package/src/watchLoad.js +0 -73
  162. package/src/zip.js +0 -69
package/src/vfs.js DELETED
@@ -1,227 +0,0 @@
1
- "use strict";
2
- // This file is part of HFS - Copyright 2021-2022, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.cantReadStatusCode = exports.walkNode = exports.hasPermission = exports.nodeIsDirectory = exports.getNodeName = exports.saveVfs = exports.vfs = exports.urlToNode = exports.MIME_AUTO = exports.defaultPerms = void 0;
8
- const promises_1 = __importDefault(require("fs/promises"));
9
- const path_1 = require("path");
10
- const micromatch_1 = require("micromatch");
11
- const misc_1 = require("./misc");
12
- const lodash_1 = __importDefault(require("lodash"));
13
- const config_1 = require("./config");
14
- const const_1 = require("./const");
15
- const events_1 = __importDefault(require("./events"));
16
- const perm_1 = require("./perm");
17
- const misc_2 = require("./misc");
18
- const WHO_ANYONE = true;
19
- const WHO_NO_ONE = false;
20
- const WHO_ANY_ACCOUNT = '*';
21
- exports.defaultPerms = {
22
- can_see: WHO_ANYONE,
23
- can_read: WHO_ANYONE,
24
- };
25
- exports.MIME_AUTO = 'auto';
26
- function inheritFromParent(parent, child) {
27
- var _a;
28
- for (const k of (0, misc_1.typedKeys)(exports.defaultPerms)) {
29
- const v = parent[k];
30
- if (v !== undefined)
31
- (_a = child[k]) !== null && _a !== void 0 ? _a : (child[k] = v);
32
- }
33
- if (typeof parent.mime === 'object' && typeof child.mime === 'object')
34
- lodash_1.default.defaults(child.mime, parent.mime);
35
- else
36
- child.mime || (child.mime = parent.mime);
37
- return child;
38
- }
39
- async function urlToNode(url, ctx, parent = exports.vfs) {
40
- var _a;
41
- let i = url.indexOf('/', 1);
42
- const name = decodeURIComponent(url.slice(url[0] === '/' ? 1 : 0, i < 0 ? undefined : i));
43
- if (!name)
44
- return parent;
45
- const rest = i < 0 ? '' : url.slice(i + 1, url.endsWith('/') ? -1 : undefined);
46
- if ((0, misc_1.dirTraversal)(name) || /[\/]/.test(name)) {
47
- if (ctx)
48
- ctx.status = 418;
49
- return;
50
- }
51
- const parents = parent.parents || []; // don't waste time cloning the array, as we won't keep intermediate nodes
52
- const ret = {
53
- isTemp: true,
54
- url: (0, misc_1.enforceFinal)('/', parent.url || '') + name,
55
- parents,
56
- };
57
- parents.push(parent);
58
- inheritFromParent(parent, ret);
59
- inheritMasks(ret, parent, name);
60
- applyMasks(ret, parent, name);
61
- // does the tree node have a child that goes by this name?
62
- const sameName = !const_1.IS_WINDOWS ? (x) => x === name // easy
63
- : (0, misc_2.with_)(name.toLowerCase(), lc => (x) => x.toLowerCase() === lc);
64
- const child = (_a = parent.children) === null || _a === void 0 ? void 0 : _a.find(x => sameName(getNodeName(x)));
65
- if (child) // yes
66
- return urlToNode(rest, ctx, Object.assign(ret, child, { original: child }));
67
- // not in the tree, we can see consider continuing on the disk
68
- if (!parent.source)
69
- return; // but then we need the current node to be linked to the disk, otherwise, we give up
70
- let onDisk = name;
71
- if (parent.rename) { // reverse the mapping
72
- for (const [from, to] of Object.entries(parent.rename))
73
- if (name === to) {
74
- onDisk = from;
75
- break; // found, search no more
76
- }
77
- ret.rename = renameUnderPath(parent.rename, name);
78
- }
79
- ret.source = (0, misc_1.enforceFinal)('/', parent.source) + onDisk;
80
- if (parent.default)
81
- inheritFromParent({ mime: { '*': exports.MIME_AUTO } }, ret);
82
- if (rest)
83
- return urlToNode(rest, ctx, ret);
84
- if (ret.source)
85
- try {
86
- await promises_1.default.stat(ret.source);
87
- } // check existence
88
- catch (_b) {
89
- return;
90
- }
91
- return ret;
92
- }
93
- exports.urlToNode = urlToNode;
94
- exports.vfs = {};
95
- (0, config_1.defineConfig)('vfs', {}).sub(data => exports.vfs = data);
96
- function saveVfs() {
97
- return (0, config_1.setConfig)({ vfs: lodash_1.default.cloneDeep(exports.vfs) }, true);
98
- }
99
- exports.saveVfs = saveVfs;
100
- function getNodeName(node) {
101
- return node.name
102
- || node.source && (/^[a-zA-Z]:\\?$/.test(node.source) && node.source.slice(0, 2)
103
- || (0, path_1.basename)(node.source)
104
- || node.source)
105
- || ''; // should happen only for root
106
- }
107
- exports.getNodeName = getNodeName;
108
- async function nodeIsDirectory(node) {
109
- return Boolean(!node.source || await (0, misc_1.isDirectory)(node.source));
110
- }
111
- exports.nodeIsDirectory = nodeIsDirectory;
112
- function hasPermission(node, perm, ctx) {
113
- var _a;
114
- return matchWho((_a = node[perm]) !== null && _a !== void 0 ? _a : exports.defaultPerms[perm], ctx)
115
- && (perm !== 'can_see' || hasPermission(node, 'can_read', ctx)); // for can_see you must also can_read
116
- }
117
- exports.hasPermission = hasPermission;
118
- async function* walkNode(parent, ctx, depth = 0, prefixPath = '') {
119
- var _a;
120
- const { children, source } = parent;
121
- if (children)
122
- for (let idx = 0; idx < children.length; idx++) {
123
- const child = children[idx];
124
- yield* workItem({
125
- ...child,
126
- name: prefixPath ? (prefixPath + getNodeName(child)) : child.name
127
- }, depth > 0 && await nodeIsDirectory(child).catch(() => false));
128
- }
129
- if (!source)
130
- return;
131
- try {
132
- for await (const path of (0, misc_1.dirStream)(source, depth)) {
133
- if (ctx === null || ctx === void 0 ? void 0 : ctx.req.aborted)
134
- return;
135
- const renamed = (_a = parent.rename) === null || _a === void 0 ? void 0 : _a[path];
136
- yield* workItem({
137
- name: prefixPath + (renamed || path),
138
- source: (0, path_1.join)(source, path),
139
- rename: renameUnderPath(parent.rename, path),
140
- });
141
- }
142
- }
143
- catch (e) {
144
- console.debug('glob', source, e); // ENOTDIR, or lacking permissions
145
- }
146
- // item will be changed, so be sure to pass a temp node
147
- async function* workItem(item, recur = false) {
148
- const name = getNodeName(item);
149
- // we basename for depth>0 where we already have the rest of the path in the parent's url, and would be duplicated
150
- const virtualBasename = (0, path_1.basename)(name);
151
- const url = (0, misc_1.enforceFinal)('/', parent.url || '') + virtualBasename;
152
- Object.assign(item, {
153
- isTemp: true,
154
- url,
155
- parents: [...parent.parents || [], parent],
156
- });
157
- inheritFromParent(parent, item);
158
- applyMasks(item, parent, virtualBasename);
159
- if (ctx && !hasPermission(item, 'can_see', ctx))
160
- return;
161
- yield item;
162
- if (!recur)
163
- return;
164
- inheritMasks(item, parent, virtualBasename);
165
- yield* walkNode(item, ctx, depth - 1, name + '/');
166
- }
167
- }
168
- exports.walkNode = walkNode;
169
- function applyMasks(item, parent, virtualBasename) {
170
- const { masks } = parent;
171
- if (!masks)
172
- return;
173
- for (const k in masks)
174
- if (k.startsWith('**/') && (0, micromatch_1.isMatch)(virtualBasename, k.slice(3))
175
- || !k.includes('/') && (0, micromatch_1.isMatch)(virtualBasename, k))
176
- Object.assign(item, masks[k]);
177
- }
178
- function inheritMasks(item, parent, virtualBasename) {
179
- const { masks } = parent;
180
- if (!masks)
181
- return;
182
- const o = {};
183
- for (const k in masks)
184
- if (k.startsWith('**/'))
185
- o[k.slice(3)] = masks[k];
186
- else if (k.startsWith(virtualBasename + '/'))
187
- o[k.slice(virtualBasename.length + 1)] = masks[k];
188
- if (Object.keys(o).length)
189
- item.masks = o;
190
- }
191
- function renameUnderPath(rename, path) {
192
- if (!rename)
193
- return rename;
194
- const match = path + '/';
195
- rename = Object.fromEntries(Object.entries(rename).map(([k, v]) => [k.startsWith(match) ? k.slice(match.length) : '', v]));
196
- delete rename[''];
197
- return lodash_1.default.isEmpty(rename) ? undefined : rename;
198
- }
199
- function matchWho(who, ctx) {
200
- return who === WHO_ANYONE
201
- || who === WHO_ANY_ACCOUNT && Boolean(ctx.state.account)
202
- || Array.isArray(who) && (() => // check if I or any ancestor match `who`, but cache ancestors' usernames inside context state
203
- (0, misc_1.getOrSet)(ctx.state, 'usernames', () => (0, perm_1.getCurrentUsernameExpanded)(ctx)).some((u) => who.includes(u)))();
204
- }
205
- function cantReadStatusCode(node) {
206
- return node.can_read === false ? const_1.FORBIDDEN : const_1.UNAUTHORIZED;
207
- }
208
- exports.cantReadStatusCode = cantReadStatusCode;
209
- events_1.default.on('accountRenamed', (from, to) => {
210
- recur(exports.vfs);
211
- saveVfs();
212
- function recur(n) {
213
- var _a;
214
- replace(n.can_see);
215
- replace(n.can_read);
216
- if (n.masks)
217
- Object.values(n.masks).forEach(recur);
218
- (_a = n.children) === null || _a === void 0 ? void 0 : _a.forEach(recur);
219
- }
220
- function replace(a) {
221
- if (!Array.isArray(a))
222
- return;
223
- for (let i = 0; i < a.length; i++)
224
- if (a[i] === from)
225
- a[i] = to;
226
- }
227
- });
package/src/watchLoad.js DELETED
@@ -1,73 +0,0 @@
1
- "use strict";
2
- // This file is part of HFS - Copyright 2021-2022, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.watchLoad = void 0;
8
- const fs_1 = require("fs");
9
- const promises_1 = __importDefault(require("fs/promises"));
10
- const yaml_1 = __importDefault(require("yaml"));
11
- const misc_1 = require("./misc");
12
- function watchLoad(path, parser, { failedOnFirstAttempt } = {}) {
13
- let doing = false;
14
- let watcher;
15
- const debounced = (0, misc_1.debounceAsync)(load, 500, { leading: true });
16
- let retry;
17
- let saving;
18
- let lastStats;
19
- init().then(ok => ok || (failedOnFirstAttempt === null || failedOnFirstAttempt === void 0 ? void 0 : failedOnFirstAttempt()));
20
- return {
21
- unwatch() {
22
- watcher === null || watcher === void 0 ? void 0 : watcher.close();
23
- clearTimeout(retry);
24
- watcher = undefined;
25
- },
26
- save(...args) {
27
- return Promise.resolve(saving).then(() => // wait in case another is ongoing
28
- saving = promises_1.default.writeFile(...args).finally(() => // save but also keep track of the current operation
29
- saving = undefined)); // clear
30
- }
31
- };
32
- async function init() {
33
- try {
34
- debounced().then();
35
- watcher = (0, fs_1.watch)(path, () => {
36
- if (!saving)
37
- debounced().then();
38
- });
39
- return true; // used actually just by the first invocation
40
- }
41
- catch (e) {
42
- retry = setTimeout(init, 3000); // manual watching until watch is successful
43
- }
44
- }
45
- async function load() {
46
- if (doing)
47
- return;
48
- doing = true;
49
- let data;
50
- try {
51
- try { // I've seen watch() firing 'change' without any change, so we'll check if any change is detectable before going on
52
- const stats = await promises_1.default.stat(path);
53
- if (stats.mtimeMs === (lastStats === null || lastStats === void 0 ? void 0 : lastStats.mtimeMs))
54
- return;
55
- lastStats = stats;
56
- data = await (0, misc_1.readFileBusy)(path);
57
- console.debug('loaded', path);
58
- }
59
- catch (e) {
60
- if (e.code === 'EPERM')
61
- console.error("missing permissions on file", path); // warn user, who could be clueless about this problem
62
- return; // ignore read errors
63
- }
64
- if (path.endsWith('.yaml'))
65
- data = yaml_1.default.parse(data);
66
- await parser(data);
67
- }
68
- finally {
69
- doing = false;
70
- }
71
- }
72
- }
73
- exports.watchLoad = watchLoad;
package/src/zip.js DELETED
@@ -1,69 +0,0 @@
1
- "use strict";
2
- // This file is part of HFS - Copyright 2021-2022, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.zipStreamFromFolder = void 0;
8
- const vfs_1 = require("./vfs");
9
- const misc_1 = require("./misc");
10
- const QuickZipStream_1 = require("./QuickZipStream");
11
- const fs_1 = require("fs");
12
- const promises_1 = __importDefault(require("fs/promises"));
13
- const config_1 = require("./config");
14
- const path_1 = require("path");
15
- const serveFile_1 = require("./serveFile");
16
- async function zipStreamFromFolder(node, ctx) {
17
- ctx.status = 200;
18
- ctx.mime = 'zip';
19
- const name = (0, vfs_1.getNodeName)(node);
20
- ctx.attachment((name || 'archive') + '.zip');
21
- const filter = (0, misc_1.pattern2filter)(String(ctx.query.search || ''));
22
- const { list } = ctx.query;
23
- const walker = !list ? (0, vfs_1.walkNode)(node, ctx, Infinity)
24
- : (async function* () {
25
- for await (const el of String(list).split('*')) { // we are using * as separator because it cannot be used in a file name and doesn't need url encoding
26
- const subNode = await (0, vfs_1.urlToNode)(el, ctx, node);
27
- if (!subNode || !(0, vfs_1.hasPermission)(subNode, 'can_read', ctx))
28
- continue;
29
- if (await (0, vfs_1.nodeIsDirectory)(subNode)) { // a directory needs to walked
30
- yield* (0, vfs_1.walkNode)(subNode, ctx, Infinity, el + '/');
31
- continue;
32
- }
33
- let folder = (0, path_1.dirname)(el);
34
- folder = folder === '.' ? '' : folder + '/';
35
- yield { ...subNode, name: folder + (0, vfs_1.getNodeName)(subNode) }; // reflect relative path in archive, otherwise way may have name-clashes
36
- }
37
- })();
38
- const mappedWalker = (0, misc_1.filterMapGenerator)(walker, async (el) => {
39
- const { source } = el;
40
- const name = (0, vfs_1.getNodeName)(el);
41
- if (!source || ctx.req.aborted || !filter(name))
42
- return;
43
- try {
44
- const st = await promises_1.default.stat(source);
45
- if (!st || !st.isFile())
46
- return;
47
- return {
48
- path: name,
49
- size: st.size,
50
- ts: st.mtime || st.ctime,
51
- mode: st.mode,
52
- sourcePath: source,
53
- getData: () => (0, fs_1.createReadStream)(source, { start: 0, end: Math.max(0, st.size - 1) })
54
- };
55
- }
56
- catch (_a) { }
57
- });
58
- const zip = new QuickZipStream_1.QuickZipStream(mappedWalker);
59
- const time = 1000 * zipSeconds.get();
60
- ctx.response.length = await zip.calculateSize(time);
61
- const range = (0, serveFile_1.getRange)(ctx, ctx.response.length);
62
- if (range)
63
- zip.applyRange(range.start, range.end);
64
- ctx.body = zip;
65
- ctx.req.on('close', () => zip.destroy());
66
- ctx.state.archive = 'zip';
67
- }
68
- exports.zipStreamFromFolder = zipStreamFromFolder;
69
- const zipSeconds = (0, config_1.defineConfig)('zip_calculate_size_for_seconds', 1);