File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,9 @@ module.exports = class RandomAccessFile extends RandomAccessStorage {
226
226
fs . unlink ( this . filename , onunlink )
227
227
228
228
function onunlink ( err ) {
229
+ // if the file isn't there, its already unlinked, ignore
230
+ if ( err && err . code === 'ENOENT' ) err = null
231
+
229
232
if ( ! self . _rmdir || ! root || dir === root ) return req . callback ( err )
230
233
fs . rmdir ( dir , onrmdir )
231
234
}
Original file line number Diff line number Diff line change @@ -439,6 +439,20 @@ test('unlink', async function (t) {
439
439
}
440
440
} )
441
441
442
+ test ( 'unlink on uncreated file does not reject' , async function ( t ) {
443
+ t . plan ( 2 )
444
+ const name = gen ( )
445
+
446
+ const file = new RAF ( name )
447
+ t . is ( fs . existsSync ( file . filename ) , false ) // Not yet created, since no write
448
+
449
+ file . unlink ( onunlink )
450
+
451
+ function onunlink ( err ) {
452
+ t . absent ( err , 'no error' )
453
+ }
454
+ } )
455
+
442
456
test ( 'pool' , function ( t ) {
443
457
t . plan ( 8 )
444
458
You can’t perform that action at this time.
0 commit comments