File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ module.exports = function (options) {
6363 const readableStream = ipfs . files . readReadableStream ( readPath )
6464
6565 readableStream . on ( 'error' , ( error ) => {
66- if ( error . toString ( ) . indexOf ( 'does not exist' ) > - 1 || error . toString ( ) . indexOf ( 'Not a directory' ) > - 1 ) {
66+ if ( isNotFoundError ( error ) ) {
6767 error . notFound = true
6868 }
6969 } )
@@ -80,15 +80,15 @@ module.exports = function (options) {
8080
8181 log ( `stat ${ statPath } ` )
8282 ipfs . files . stat ( statPath , { } , ( error ) => {
83- if ( error ) {
84- if ( error . toString ( ) . indexOf ( 'does not exist' ) > - 1 || error . toString ( ) . indexOf ( 'Not a directory' ) > - 1 ) {
85- return cb ( null , false )
86- }
83+ if ( ! error ) {
84+ return cb ( null , true )
85+ }
8786
88- return cb ( error )
87+ if ( isNotFoundError ( error ) ) {
88+ return cb ( null , false )
8989 }
9090
91- cb ( null , true )
91+ return cb ( error )
9292 } )
9393 }
9494
@@ -111,3 +111,7 @@ function noop () {}
111111function normalisePath ( path ) {
112112 return path . replace ( / \/ ( \/ ) + / g, '/' )
113113}
114+
115+ function isNotFoundError ( error ) {
116+ return error . toString ( ) . indexOf ( 'does not exist' ) > - 1 || error . toString ( ) . indexOf ( 'Not a directory' ) > - 1
117+ }
You can’t perform that action at this time.
0 commit comments