File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -61,13 +61,13 @@ function headersInvalid (headers) {
61
61
62
62
RandomAccessHTTP . prototype . write = function ( offset , data , cb ) {
63
63
if ( ! cb ) cb = noop
64
- if ( ! this . buffer ) return cb ( new Error ( 'Instance is closed ' ) )
64
+ if ( ! this . writable ) return cb ( new Error ( 'URL is not writable ' ) )
65
65
cb ( new Error ( 'Write Not Implemented' ) )
66
66
}
67
67
68
68
RandomAccessHTTP . prototype . read = function ( offset , length , cb ) {
69
- if ( ! this . buffer ) return cb ( new Error ( 'Instance is closed' ) )
70
- if ( offset + length > this . buffer . length ) return cb ( new Error ( 'Could not satisfy length ' ) )
69
+ if ( ! this . opened ) return openAndRead ( this , offset , length , cb )
70
+ if ( ! this . readable ) return cb ( new Error ( 'File is not readable ' ) )
71
71
cb ( new Error ( 'Read Not Implemented' ) )
72
72
}
73
73
@@ -78,3 +78,10 @@ RandomAccessHTTP.prototype.close = function (cb) {
78
78
}
79
79
80
80
function noop ( ) { }
81
+
82
+ function openAndRead ( self , offset , length , cb ) {
83
+ self . open ( function ( err ) {
84
+ if ( err ) return cb ( err )
85
+ self . read ( offset , length , cb )
86
+ } )
87
+ }
You can’t perform that action at this time.
0 commit comments