From 7a0d4d9969f708abcabef2acb67850cfaaef700c Mon Sep 17 00:00:00 2001 From: v1rtl Date: Thu, 23 Jan 2025 01:47:53 +0200 Subject: [PATCH 1/2] Remove unneeded `multistream` dependency --- NOTICE.txt | 32 ------------ package-lock.json | 58 +++++---------------- package.json | 2 - src/common/persistence/FSExtentStore.ts | 24 ++++----- src/common/persistence/MemoryExtentStore.ts | 10 ++-- 5 files changed, 33 insertions(+), 93 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index 57c9c0532..3e0c814b4 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -7317,38 +7317,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ---------------------------------------------------------- - ---------------------------------------------------------- - -multistream 2.1.1 - MIT -https://github.com/feross/multistream - -Copyright (c) Feross Aboukhadijeh -Copyright (c) Feross Aboukhadijeh (http://feross.org). - -The MIT License (MIT) - -Copyright (c) Feross Aboukhadijeh - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - --------------------------------------------------------- --------------------------------------------------------- diff --git a/package-lock.json b/package-lock.json index 1956ec049..78a413eb8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,6 @@ "jsonwebtoken": "^9.0.0", "lokijs": "^1.5.6", "morgan": "^1.9.1", - "multistream": "^2.1.1", "mysql2": "^3.10.1", "rimraf": "^3.0.2", "sequelize": "^6.31.0", @@ -55,7 +54,6 @@ "@types/lokijs": "^1.5.2", "@types/mocha": "^9.0.0", "@types/morgan": "^1.7.35", - "@types/multistream": "^2.1.1", "@types/node": "^14.14.24", "@types/rimraf": "^3.0.0", "@types/stoppable": "^1.1.1", @@ -1301,15 +1299,6 @@ "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" }, - "node_modules/@types/multistream": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@types/multistream/-/multistream-2.1.2.tgz", - "integrity": "sha512-Q0LINZC7Q2HE+M7uMh2QZp54F/4wz+8Vs6IEXCmeboxb3EScvqczARXPmGjP8GrEbLf68haIUjfWuQw9/kB63w==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/node": { "version": "14.14.24", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.24.tgz", @@ -3566,7 +3555,8 @@ "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true }, "node_modules/create-require": { "version": "1.1.1", @@ -6296,7 +6286,8 @@ "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true }, "node_modules/isexe": { "version": "2.0.0", @@ -7354,15 +7345,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "node_modules/multistream": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/multistream/-/multistream-2.1.1.tgz", - "integrity": "sha512-xasv76hl6nr1dEy3lPvy7Ej7K/Lx3O/FCvwge8PeVJpciPPoNCbaANcNiBug3IpdvTveZUcAV0DJzdnUDMesNQ==", - "dependencies": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.5" - } - }, "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -8209,7 +8191,8 @@ "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true }, "node_modules/progress": { "version": "2.0.3", @@ -8369,6 +8352,7 @@ "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, "dependencies": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", @@ -11308,15 +11292,6 @@ "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz", "integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==" }, - "@types/multistream": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@types/multistream/-/multistream-2.1.2.tgz", - "integrity": "sha512-Q0LINZC7Q2HE+M7uMh2QZp54F/4wz+8Vs6IEXCmeboxb3EScvqczARXPmGjP8GrEbLf68haIUjfWuQw9/kB63w==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/node": { "version": "14.14.24", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.24.tgz", @@ -13186,7 +13161,8 @@ "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true }, "create-require": { "version": "1.1.1", @@ -15126,7 +15102,8 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true }, "isexe": { "version": "2.0.0", @@ -15944,15 +15921,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "multistream": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/multistream/-/multistream-2.1.1.tgz", - "integrity": "sha512-xasv76hl6nr1dEy3lPvy7Ej7K/Lx3O/FCvwge8PeVJpciPPoNCbaANcNiBug3IpdvTveZUcAV0DJzdnUDMesNQ==", - "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.5" - } - }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -16560,7 +16528,8 @@ "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true }, "progress": { "version": "2.0.3", @@ -16676,6 +16645,7 @@ "version": "2.3.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", diff --git a/package.json b/package.json index 28b7bdd6f..6835e398c 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "jsonwebtoken": "^9.0.0", "lokijs": "^1.5.6", "morgan": "^1.9.1", - "multistream": "^2.1.1", "mysql2": "^3.10.1", "rimraf": "^3.0.2", "sequelize": "^6.31.0", @@ -60,7 +59,6 @@ "@types/lokijs": "^1.5.2", "@types/mocha": "^9.0.0", "@types/morgan": "^1.7.35", - "@types/multistream": "^2.1.1", "@types/node": "^14.14.24", "@types/rimraf": "^3.0.0", "@types/stoppable": "^1.1.1", diff --git a/src/common/persistence/FSExtentStore.ts b/src/common/persistence/FSExtentStore.ts index 31eedb31a..7516d1010 100644 --- a/src/common/persistence/FSExtentStore.ts +++ b/src/common/persistence/FSExtentStore.ts @@ -9,9 +9,8 @@ import { stat, unlink } from "fs"; -import multistream = require("multistream"); import { join } from "path"; -import { Writable } from "stream"; +import { PassThrough, Writable, pipeline } from "stream"; import { promisify } from "util"; import uuid = require("uuid"); @@ -350,10 +349,8 @@ export default class FSExtentStore implements IExtentStore { const op = () => new Promise((resolve, reject) => { this.logger.verbose( - `FSExtentStore:readExtent() Creating read stream. LocationId:${persistencyId} extentId:${ - extentChunk.id - } path:${path} offset:${extentChunk.offset} count:${ - extentChunk.count + `FSExtentStore:readExtent() Creating read stream. LocationId:${persistencyId} extentId:${extentChunk.id + } path:${path} offset:${extentChunk.offset} count:${extentChunk.count } end:${extentChunk.offset + extentChunk.count - 1}`, contextId ); @@ -362,10 +359,8 @@ export default class FSExtentStore implements IExtentStore { end: extentChunk.offset + extentChunk.count - 1 }).on("close", () => { this.logger.verbose( - `FSExtentStore:readExtent() Read stream closed. LocationId:${persistencyId} extentId:${ - extentChunk.id - } path:${path} offset:${extentChunk.offset} count:${ - extentChunk.count + `FSExtentStore:readExtent() Read stream closed. LocationId:${persistencyId} extentId:${extentChunk.id + } path:${path} offset:${extentChunk.offset} count:${extentChunk.count } end:${extentChunk.offset + extentChunk.count - 1}`, contextId ); @@ -449,7 +444,12 @@ export default class FSExtentStore implements IExtentStore { ); } - return multistream(streams); + const writable = pipeline(streams); + const passthrough = new PassThrough(); + + passthrough.pipe(writable); + + return passthrough; } /** @@ -561,7 +561,7 @@ export default class FSExtentStore implements IExtentStore { )}, after ${count} bytes piped. Reject streamPipe().`, contextId ); - + reject(err); }); diff --git a/src/common/persistence/MemoryExtentStore.ts b/src/common/persistence/MemoryExtentStore.ts index 1f5325e35..3b90e343c 100644 --- a/src/common/persistence/MemoryExtentStore.ts +++ b/src/common/persistence/MemoryExtentStore.ts @@ -4,8 +4,7 @@ import ZeroBytesStream from "../ZeroBytesStream"; import IExtentMetadataStore, { IExtentModel } from "./IExtentMetadataStore"; import IExtentStore, { IExtentChunk } from "./IExtentStore"; import uuid = require("uuid"); -import multistream = require("multistream"); -import { Readable } from "stream"; +import { PassThrough, Readable, pipeline } from "stream"; import { totalmem } from "os"; export interface IMemoryExtentChunk extends IExtentChunk { @@ -367,7 +366,12 @@ export default class MemoryExtentStore implements IExtentStore { ); } - return multistream(streams); + const writable = pipeline(streams); + const passthrough = new PassThrough(); + + passthrough.pipe(writable); + + return passthrough; } async deleteExtents(extents: Iterable): Promise { From eb2147753e00428ed5362d06e026f30984e2356a Mon Sep 17 00:00:00 2001 From: v1rtl Date: Thu, 23 Jan 2025 01:50:29 +0200 Subject: [PATCH 2/2] Update changelog --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index afba0aec0..cc8e29ce3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -15,6 +15,7 @@ Blob: - Fixed issue of download 0 size blob with range > 0 should have header "Content-Range: bytes \*/0" in returned error. (issue #2458) - Aligned behavior with Azure to ignore invalid range requests for blob downloads. (issue #2458) - Consider both Content-MD5 and x-ms-blob-content-md5 when creating a blob. +- Remove unneeded dependency on multistream. Table: