Comments (3)
Hi. The reason you are seeing this is because you aren't draining the pack stream. You should change it to drain right away like so:
var fs = require("fs");
var tar = require('tar-stream');
var fileName = "demo";
var pack = tar.pack();
// lets drain the stream right away
pack.pipe(fs.createWriteStream("output.tar"));
fs.writeFileSync(fileName, new Array(1674).join("X"), "utf-8");
pack.entry({ name: "specific-length.txt" }, new Array(13399).join("X"));
fs.stat(fileName, function (err, stat) {
if (err) {
return console.log(err);
}
var packOptions = {
mode: stat.mode,
mtime: stat.mtime,
name: fileName,
size: stat.size
};
var rs = fs.createReadStream(fileName);
var entry = pack.entry(packOptions, function (err) {
console.log("This happens");
pack.finalize();
});
console.log("We pipe the stream here and expect a callback...");
return rs.pipe(entry);
});
The reason you are seeing the issue using your file sizes is because the total size exceeds the default streams2 buffer size. Let me know if this makes sense to you.
from tar-stream.
Also thanks a lot for posting a complete test case! :)
from tar-stream.
Ahhh, that makes sense. That way you can keep pushing data through instead of having it pile up in RAM. Thanks for the quick response!
from tar-stream.
Related Issues (20)
- All file attributes included in pax header HOT 1
- Incorrect handling of backpressure HOT 6
- How can I modify tar.gz? HOT 2
- Extract broken on Node 14 when disabling readable-stream HOT 3
- NPM Advisory - BL - Remote Memory Exposure HOT 2
- Leading slash is removed on long paths HOT 1
- Risk of unexpected exit if you forget to call .finalize, and how to eliminate this danger HOT 3
- Stream error handling HOT 1
- [Header.js] Allow attempting of extraction on unknown formats HOT 9
- all entry name are paxheader HOT 2
- "Invalid tar header: unknown format." from valid tar file, IANA tz database HOT 5
- Tar file is corrupted when using single File larger than 8 GB - tar-fs HOT 1
- Packing files at the root HOT 1
- File corrupted when combining extract with gzip HOT 2
- unable to use stream.pipeline() HOT 1
- doesn't work with HOT 2
- skipping on entry, header errors HOT 1
- zero-sized files in tarballs do not call `end` handler HOT 2
- error handling issue HOT 3
- Add browser support HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tar-stream.