minimalistic-server 0.0.35 → 0.0.37
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/index.mjs +10 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1585,7 +1585,7 @@ export class FileResponse extends Response {
|
|
|
1585
1585
|
#dataPromise = null;
|
|
1586
1586
|
|
|
1587
1587
|
#maxChunkSize = 4 * 1024 * 1024;
|
|
1588
|
-
#
|
|
1588
|
+
#maxFragmentSize = 16 * 1024 * 1024 * 1024;
|
|
1589
1589
|
#fragmentRequestMap = new WeakMap();
|
|
1590
1590
|
#makeNotFoundResponse = null;
|
|
1591
1591
|
#urlPathForDirectory = null;
|
|
@@ -1714,7 +1714,7 @@ export class FileResponse extends Response {
|
|
|
1714
1714
|
offset = data.size - 1;
|
|
1715
1715
|
}
|
|
1716
1716
|
|
|
1717
|
-
let size = (numbers[1] ?? (this.#
|
|
1717
|
+
let size = (numbers[1] ?? (this.#maxFragmentSize - 1 + offset)) - offset + 1;
|
|
1718
1718
|
|
|
1719
1719
|
if (size < 0) {
|
|
1720
1720
|
size = 0;
|
|
@@ -1789,11 +1789,12 @@ ${urlPath ? `<a href="/${parentUrlPath}">Up</a><hr>` : ''}
|
|
|
1789
1789
|
try {
|
|
1790
1790
|
const requestedPosition = fragmentRequest?.offset ?? 0;
|
|
1791
1791
|
const requestedSize = fragmentRequest?.size ?? data.size;
|
|
1792
|
+
const maxChunkSize = fragmentRequest ? 256 * 1024 : this.#maxChunkSize;
|
|
1792
1793
|
|
|
1793
1794
|
filehandle = await currentFsPromiseModule.open(this.#filePath, 'r');
|
|
1794
1795
|
|
|
1795
|
-
for (let offset = 0; offset < requestedSize && !this.#blocked; offset +=
|
|
1796
|
-
const size = Math.min(
|
|
1796
|
+
for (let offset = 0; offset < requestedSize && !this.#blocked; offset += maxChunkSize) {
|
|
1797
|
+
const size = Math.min(maxChunkSize, requestedSize - offset);
|
|
1797
1798
|
const chunk = await filehandle.read(Buffer.alloc(size), 0, size, offset + requestedPosition);
|
|
1798
1799
|
yield chunk.buffer;
|
|
1799
1800
|
}
|
|
@@ -2247,6 +2248,11 @@ function invalidateStaticCache(path = null, clear = true) {
|
|
|
2247
2248
|
}
|
|
2248
2249
|
} else {
|
|
2249
2250
|
path = `${path}`.split('/').filter(x => x).join('/');
|
|
2251
|
+
|
|
2252
|
+
if (!clear && !staticCache.has(path)) {
|
|
2253
|
+
staticCache.set(path, new FileResponse(path));
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2250
2256
|
staticCache.get(path)?.block();
|
|
2251
2257
|
|
|
2252
2258
|
if (clear) {
|