-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix long file paths passed to
files.createTarball
The fix is actually in npm/fstream#42, but now we also remove our explicit path length check that used to throw an error instead of silently losing files. This commit also adds a self-test to test the entire flow through `files.createTarball` and `files.extractTarGz`.
- Loading branch information
Showing
3 changed files
with
31 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var selftest = require('../selftest.js'); | ||
var files = require('../files.js'); | ||
var expectEqual = selftest.expectEqual; | ||
|
||
selftest.define("create and extract tarball with long paths", function () { | ||
var STAMP = "stamp"; | ||
|
||
// Create a directory with a single file in a long subdirectory, to | ||
// be turned into a tarball. | ||
var tarballInputDir = files.mkdtemp("tarball-input"); | ||
var longDir = tarballInputDir; | ||
while (longDir.length < 300) { | ||
longDir = files.pathJoin(longDir, "subdirectory"); | ||
} | ||
files.mkdir_p(longDir); | ||
var inputStampedFile = files.pathJoin(longDir, "file"); | ||
files.writeFile(inputStampedFile, STAMP); | ||
|
||
// Make the tarball | ||
var tarballOutputDir = files.mkdtemp("tarball"); | ||
var tarballOutputFile = files.pathJoin(tarballOutputDir, "out.tar.gz"); | ||
files.createTarball(tarballInputDir, tarballOutputFile); | ||
|
||
// Extract the tarball and verify that the single file we created is | ||
// present with the expected contents. | ||
var tarballExtractedDir = files.mkdtemp("tarball-extracted"); | ||
files.extractTarGz(files.readFile(tarballOutputFile), tarballExtractedDir); | ||
var extractedStampedFile = inputStampedFile.replace(tarballInputDir, tarballExtractedDir); | ||
expectEqual(files.readFile(extractedStampedFile, "utf-8"), STAMP); | ||
}); |
(I looked at the changes since 1.0.2 and them seem to only contain changes to improve error handling.)