@@ -150,7 +150,7 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
150
150
} )
151
151
152
152
if ( this . header . encode ( ) && ! this . noPax ) {
153
- this . write ( new Pax ( {
153
+ super . write ( new Pax ( {
154
154
atime : this . portable ? null : this . header . atime ,
155
155
ctime : this . portable ? null : this . header . ctime ,
156
156
gid : this . portable ? null : this . header . gid ,
@@ -165,7 +165,7 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
165
165
nlink : this . portable ? null : this . stat . nlink ,
166
166
} ) . encode ( ) )
167
167
}
168
- this . write ( this . header . block )
168
+ super . write ( this . header . block )
169
169
}
170
170
171
171
[ DIRECTORY ] ( ) {
@@ -286,10 +286,6 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
286
286
287
287
const writeBuf = this . offset === 0 && bytesRead === this . buf . length ?
288
288
this . buf : this . buf . slice ( this . offset , this . offset + bytesRead )
289
- this . remain -= writeBuf . length
290
- this . blockRemain -= writeBuf . length
291
- this . pos += writeBuf . length
292
- this . offset += writeBuf . length
293
289
294
290
const flushed = this . write ( writeBuf )
295
291
if ( ! flushed )
@@ -302,10 +298,23 @@ const WriteEntry = warner(class WriteEntry extends MiniPass {
302
298
this . once ( 'drain' , cb )
303
299
}
304
300
301
+ write ( writeBuf ) {
302
+ if ( this . blockRemain < writeBuf . length ) {
303
+ const er = new Error ( 'writing more data than expected' )
304
+ er . path = this . absolute
305
+ return this . emit ( 'error' , er )
306
+ }
307
+ this . remain -= writeBuf . length
308
+ this . blockRemain -= writeBuf . length
309
+ this . pos += writeBuf . length
310
+ this . offset += writeBuf . length
311
+ return super . write ( writeBuf )
312
+ }
313
+
305
314
[ ONDRAIN ] ( ) {
306
315
if ( ! this . remain ) {
307
316
if ( this . blockRemain )
308
- this . write ( Buffer . alloc ( this . blockRemain ) )
317
+ super . write ( Buffer . alloc ( this . blockRemain ) )
309
318
return this [ CLOSE ] ( er => er ? this . emit ( 'error' , er ) : this . end ( ) )
310
319
}
311
320
@@ -461,7 +470,7 @@ const WriteEntryTar = warner(class WriteEntryTar extends MiniPass {
461
470
462
471
end ( ) {
463
472
if ( this . blockRemain )
464
- this . write ( Buffer . alloc ( this . blockRemain ) )
473
+ super . write ( Buffer . alloc ( this . blockRemain ) )
465
474
return super . end ( )
466
475
}
467
476
} )
0 commit comments