Skip to content

Commit

Permalink
* Cleanup of changes in last commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Venryx committed Jul 10, 2024
1 parent 12841a4 commit 847c12c
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions Scripts/DBBackups/GQLBackupHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,30 +145,7 @@ function WriteStreamContentsToFileStream(stream, filePath) {
return new Promise((resolve, reject)=>{
const fileStream = fs.createWriteStream(filePath);
pipeline.on("error", reject);
/*pipeline.on("data", async val=>{
// only create write-stream once we've confirmed that there is data to write
if (fileStream == null) {
fileStream = fs.createWriteStream(filePath);
}
charsWritten += val.length;
fileStream.write(val);
});*/
/*pipeline.on("readable", async ()=>{
console.log("NewReadable");
let val;
while (null !== (val = pipeline.read())) {
fileStream ??= fs.createWriteStream(filePath, {
highWaterMark: 10000,
});
charsWritten += val.length;
if (!fileStream.write(val)) {
/*console.log("Wait");
await new Promise(resolve=>fileStream.once("drain", resolve));
console.log("Done");*#/
}
}
console.log("Test1");
});*/
// we use pipe rather than a manual "data" listener, because pipe() keeps memory usage much lower (~100mb rather than 5gb+) [reason: I think pipe() handles "stream backpressure" correctly]
pipeline.pipe(fileStream);
pipeline.on("end", ()=>{
// calling end() is better than close(), as end() waits for the buffer to be flushed before closing the stream (https://github.com/nodejs/node/issues/5631#issuecomment-194509781)
Expand Down

0 comments on commit 847c12c

Please sign in to comment.