@@ -41,9 +41,13 @@ var ZipArchiveOutputStream = module.exports = function(options) {
4141
4242inherits ( ZipArchiveOutputStream , ArchiveOutputStream ) ;
4343
44- ZipArchiveOutputStream . prototype . _afterAppend = function ( zae ) {
45- this . _entries . push ( zae ) ;
46- this . _writeDataDescriptor ( zae ) ;
44+ ZipArchiveOutputStream . prototype . _afterAppend = function ( ae ) {
45+ this . _entries . push ( ae ) ;
46+
47+ if ( ae . getGeneralPurposeBit ( ) . usesDataDescriptor ( ) ) {
48+ this . _writeDataDescriptor ( ae ) ;
49+ }
50+
4751
4852 this . _archive . processing = false ;
4953 this . _entry = null ;
@@ -116,7 +120,10 @@ ZipArchiveOutputStream.prototype._finish = function() {
116120
117121 this . _archive . centralLength = this . offset - this . _archive . centralOffset ;
118122
119- this . _writeCentralDirectoryZip64 ( ) ;
123+ if ( this . isZip64 ( ) ) {
124+ this . _writeCentralDirectoryZip64 ( ) ;
125+ }
126+
120127 this . _writeCentralDirectoryEnd ( ) ;
121128
122129 this . _archive . processing = false ;
@@ -200,10 +207,6 @@ ZipArchiveOutputStream.prototype._writeCentralDirectoryEnd = function() {
200207} ;
201208
202209ZipArchiveOutputStream . prototype . _writeCentralDirectoryZip64 = function ( ) {
203- if ( ! this . isZip64 ( ) ) {
204- return ;
205- }
206-
207210 // signature
208211 this . write ( constants . SIG_ZIP64_EOCD ) ;
209212
@@ -336,10 +339,6 @@ ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) {
336339} ;
337340
338341ZipArchiveOutputStream . prototype . _writeDataDescriptor = function ( ae ) {
339- if ( ! ae . getGeneralPurposeBit ( ) . usesDataDescriptor ( ) ) {
340- return ;
341- }
342-
343342 // signature
344343 this . write ( zipUtil . getLongBytes ( constants . SIG_DD ) ) ;
345344
0 commit comments