File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ module.exports = class RandomAccessFile extends RandomAccessStorage {
108108 function onlock ( err ) {
109109 if ( err ) return onerrorafteropen ( err )
110110
111- if ( ! self . _sparse || ! fsext ) return onsparse ( null )
111+ if ( ! self . _sparse || ! fsext || self . mode === RDONLY ) return onsparse ( null )
112112
113113 fsext . sparse ( self . fd ) . then ( onsparse , onsparse )
114114 }
Original file line number Diff line number Diff line change 1818 "fs-native-extensions" : " ^1.1.0"
1919 },
2020 "devDependencies" : {
21- "brittle" : " ^3.0.4 " ,
21+ "brittle" : " ^3.3.0 " ,
2222 "standard" : " ^17.0.0"
2323 },
2424 "repository" : {
Original file line number Diff line number Diff line change @@ -502,6 +502,24 @@ test('readonly mode', function (t) {
502502 } )
503503} )
504504
505+ test ( 'readonly mode + sparse' , function ( t ) {
506+ t . plan ( 1 )
507+
508+ const filename = gen ( )
509+ const f = new RAF ( filename , { sparse : true } )
510+
511+ f . write ( 0 , Buffer . from ( 'hello world' ) , function ( ) {
512+ f . close ( function ( ) {
513+ const r = new RAF ( filename , { writable : false , sparse : true } )
514+
515+ r . read ( 0 , 5 , function ( _ , data ) {
516+ t . alike ( data , Buffer . from ( 'hello' ) )
517+ r . close ( )
518+ } )
519+ } )
520+ } )
521+ } )
522+
505523function gen ( ) {
506524 return path . join ( tmp , ++ i + '.txt' )
507525}
You can’t perform that action at this time.
0 commit comments