Comparing version 0.4.6 to 0.4.7
@@ -19,3 +19,3 @@ /** | ||
options = util.defaults(options, { | ||
highWaterMark: 64 * 1024 | ||
highWaterMark: 512 * 1024 | ||
}); | ||
@@ -52,3 +52,4 @@ | ||
Archiver.prototype._transform = function(chunk, encoding, callback) { | ||
callback(null, chunk); | ||
this._push(chunk); | ||
callback(); | ||
}; | ||
@@ -74,3 +75,7 @@ | ||
Archiver.prototype._processQueue = function() { | ||
Archiver.prototype._processQueue = function(finishedLast) { | ||
if (finishedLast === true) { | ||
this.archiver.processing = false; | ||
} | ||
if (this.archiver.processing) { | ||
@@ -83,2 +88,3 @@ return; | ||
this.archiver.processing = true; | ||
this._processFile(next.source, next.data, next.callback); | ||
@@ -139,12 +145,10 @@ } else if (this.archiver.finalized && this.archiver.writableEndCalled === false) { | ||
if (this.archiver.processing || this.archiver.queue.length) { | ||
this.archiver.queue.push({ | ||
data: data, | ||
source: (sourceCompatMode) ? sourceCompat : source, | ||
callback: callback | ||
}); | ||
} else { | ||
this._processFile(source, data, callback); | ||
} | ||
this.archiver.queue.push({ | ||
data: data, | ||
source: (sourceCompatMode) ? sourceCompat : source, | ||
callback: callback | ||
}); | ||
this._processQueue(); | ||
return this; | ||
@@ -151,0 +155,0 @@ }; |
@@ -52,3 +52,2 @@ /** | ||
var self = this; | ||
self.archiver.processing = true; | ||
@@ -76,6 +75,5 @@ var file = self.archiver.file = data; | ||
self.archiver.files.push(file); | ||
self.archiver.processing = false; | ||
callback(); | ||
self._processQueue(); | ||
self._processQueue(true); | ||
} | ||
@@ -82,0 +80,0 @@ |
@@ -37,3 +37,3 @@ /** | ||
ArchiverZip.prototype._flush = function(callback) { | ||
this._push(this._buildCentralDirectory()); | ||
this._buildCentralDirectory(); | ||
@@ -46,11 +46,6 @@ callback(); | ||
var comment = this.options.comment; | ||
var cdoffset = this.archiver.pointer; | ||
var ptr = 0; | ||
var cdsize = 0; | ||
var centralDirectoryBuffers = []; | ||
var centralDirectoryBuffer; | ||
for (var i = 0; i < files.length; i++) { | ||
@@ -60,8 +55,7 @@ var file = files[i]; | ||
centralDirectoryBuffer = headers.encode('centralDirectory', file); | ||
centralDirectoryBuffers.push(centralDirectoryBuffer); | ||
this._push(centralDirectoryBuffer); | ||
ptr += centralDirectoryBuffer.length; | ||
} | ||
cdsize = ptr; | ||
var cdsize = ptr; | ||
var centralDirectoryFooterData = { | ||
@@ -74,9 +68,5 @@ directoryRecordsDisk: files.length, | ||
}; | ||
var centralDirectoryFooterBuffer = headers.encode('centralFooter', centralDirectoryFooterData); | ||
centralDirectoryBuffers.push(centralDirectoryFooterBuffer); | ||
ptr += centralDirectoryFooterBuffer.length; | ||
return Buffer.concat(centralDirectoryBuffers, ptr); | ||
this._push(centralDirectoryFooterBuffer); | ||
}; | ||
@@ -113,3 +103,2 @@ | ||
var self = this; | ||
self.archiver.processing = true; | ||
@@ -119,2 +108,3 @@ var file = self.archiver.file = data; | ||
file.offset = self.archiver.pointer; | ||
self._push(headers.encode('file', file)); | ||
@@ -134,3 +124,2 @@ | ||
file.compressedSize = deflate.compressedSize; | ||
self.archiver.pointer += deflate.compressedSize; | ||
@@ -140,3 +129,11 @@ onend(); | ||
deflate.pipe(self, { end: false }); | ||
// archiver and deflate are having disagreements | ||
// over piping at this point in time so archiver | ||
// had to be the adult and move on with hopes of | ||
// making up in the future :) - 20130818 | ||
// deflate.pipe(self, { end: false }); | ||
deflate.on('data', function(data) { | ||
self._push(data); | ||
}); | ||
} else { | ||
@@ -151,3 +148,2 @@ checksumr = new ChecksumStream(); | ||
file.crc32 = checksumr.digest; | ||
self.archiver.pointer += checksumr.rawSize; | ||
@@ -164,6 +160,5 @@ onend(); | ||
self.archiver.files.push(file); | ||
self.archiver.processing = false; | ||
callback(); | ||
self._processQueue(); | ||
self._processQueue(true); | ||
} | ||
@@ -170,0 +165,0 @@ |
@@ -10,2 +10,3 @@ /** | ||
var inherits = require('util').inherits; | ||
var iconv = require('iconv-lite'); | ||
@@ -64,3 +65,8 @@ function HeaderZip() { | ||
if (data.name) { | ||
data.filenameLength = data.name.length; | ||
var nameUTF8 = iconv.encode(data.name, 'utf8'); | ||
data.name = iconv.decode(nameUTF8, 'utf8'); | ||
data.filenameLength = nameUTF8.length; | ||
data.flags |= (1<<11); | ||
} | ||
@@ -67,0 +73,0 @@ |
@@ -80,5 +80,5 @@ /** | ||
CRC32.prototype.update = function(buffer) { | ||
for (var i = 0; i < buffer.length; i++) { | ||
this.crc = (this.crc >>> 8) ^ lookup[(this.crc ^ buffer[i]) & 0xff]; | ||
CRC32.prototype.update = function(buf) { | ||
for (var i = 0; i < buf.length; i++) { | ||
this.crc = (this.crc >>> 8) ^ lookup[(this.crc ^ buf[i]) & 0xff]; | ||
} | ||
@@ -85,0 +85,0 @@ |
{ | ||
"name": "archiver", | ||
"version": "0.4.6", | ||
"version": "0.4.7", | ||
"description": "Creates Archives (ZIP) via Node Streams.", | ||
@@ -36,6 +36,7 @@ "homepage": "https://github.com/ctalkington/node-archiver", | ||
"chai": "~1.7.1", | ||
"mocha": "~1.11.0", | ||
"mocha": "~1.12.0", | ||
"rimraf": "~2.2.0", | ||
"mkdirp": "~0.3.5", | ||
"stream-bench": "~0.1.2" | ||
"stream-bench": "~0.1.2", | ||
"iconv-lite" : "~0.2.11" | ||
}, | ||
@@ -42,0 +43,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
# Archiver v0.4.6 [![Build Status](https://secure.travis-ci.org/ctalkington/node-archiver.png?branch=master)](http://travis-ci.org/ctalkington/node-archiver) | ||
# Archiver v0.4.7 [![Build Status](https://secure.travis-ci.org/ctalkington/node-archiver.png?branch=master)](http://travis-ci.org/ctalkington/node-archiver) | ||
@@ -13,26 +13,18 @@ Creates Archives (Zip, Tar) via Node Streams. Depends on Node's built-in zlib module for compression available since version 0.6.3. | ||
## Core | ||
## Archiver | ||
### Methods | ||
#### #create(type, options) | ||
#### Archiver(type, options) | ||
Creates an Archiver instance based on the type (ie zip/tar) passed. Can be passed to `Archiver` for convenience. | ||
Convenience alias for `create`. | ||
#### create(type, options) | ||
Creates an Archiver instance based on the type (ie zip/tar) passed. | ||
### Instance Methods | ||
#### addFile(input, data, callback(err)) | ||
#### #append(input, data, callback(err)) | ||
Alias of `append` for compatibility that will be removed down the road. | ||
Appends a file to the instance. Input can be in the form of a text string, buffer, or stream. When the instance has received, processed, and emitted the input, the callback is fired. | ||
#### append(input, data, callback(err)) | ||
Replaces `#addFile` which is in the depreciation stage and set to be remove in next release. | ||
Appends a file to the instance. Input can be in the form of a text string, buffer, or stream. When the instance has received, processed, and emitted the input, the callback is fired. | ||
#### #finalize(callback(err, bytesWritten)) | ||
#### finalize(callback(err, bytesWritten)) | ||
Finalizes the instance. When the instance's stream has finished emitting, the callback is fired. | ||
@@ -64,3 +56,3 @@ | ||
Sets the file date. This can be any valid date string or object. Defaults to current time in locale. | ||
Sets the file date. This can be any valid date string or instance. Defaults to current time in locale. | ||
@@ -95,22 +87,15 @@ #### store `boolean` | ||
Sets the file date. This can be any valid date string or object. Defaults to current time in locale. | ||
Sets the file date. This can be any valid date string or instance. Defaults to current time in locale. | ||
## Examples | ||
## Things of Interest | ||
Take a peek at the [examples](https://github.com/ctalkington/node-archiver/blob/master/examples) folder for a complete listing. | ||
- [Examples](https://github.com/ctalkington/node-archiver/blob/master/examples) | ||
- [Changelog](https://github.com/ctalkington/node-archiver/blob/master/CHANGELOG) | ||
- [Contributing](https://github.com/ctalkington/node-archiver/blob/master/CONTRIBUTING.md) | ||
- [MIT License](https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT) | ||
## Contributing | ||
see [CONTRIBUTING](https://github.com/ctalkington/node-archiver/blob/master/CONTRIBUTING.md). | ||
## Changelog | ||
see [CHANGELOG](https://github.com/ctalkington/node-archiver/blob/master/CHANGELOG). | ||
## Credits | ||
Originally inspired by Antoine van Wel's [node-zipstream](https://github.com/wellawaretech/node-zipstream). | ||
Concept inspired by Antoine van Wel's [node-zipstream](https://github.com/wellawaretech/node-zipstream). | ||
## Licensing | ||
This project's code is licensed under the MIT license. see [LICENSE-MIT](https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT). | ||
Tar inspired by isaacs's [node-tar](https://github.com/isaacs/node-tar). |
@@ -337,2 +337,22 @@ /*global before,describe,it */ | ||
}); | ||
it('should properly handle accented characters in filenames', function(done) { | ||
var archive = archiver('zip', { | ||
forceUTC: true | ||
}); | ||
var testStream = new WriteHashStream('tmp/accentedchars-filenames.zip'); | ||
testStream.on('close', function() { | ||
assert.equal(testStream.digest, '69194ccb7175d7fcfcb06c8cb0ed2c429dadb9f9'); | ||
done(); | ||
}); | ||
archive.pipe(testStream); | ||
archive | ||
.append(binaryBuffer(20000), { name: 'àáâãäçèéêëìíîïñòóôõöùúûüýÿ.txt', date: testDate }) | ||
.append(binaryBuffer(20000), { name: 'ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ.txt', date: testDate2 }) | ||
.finalize(); | ||
}); | ||
}); | ||
@@ -339,0 +359,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83210
2000
6
99