@@ -236,24 +236,39 @@ class FuseManager extends EventEmitter {
236
236
}
237
237
}
238
238
239
+ _getMountPath ( path ) {
240
+ if ( ! this . _rootDrive && path !== '/hyperdrive' ) throw new Error ( 'You can only mount the root drive at /hyperdrive' )
241
+ if ( ! this . _rootDrive ) return { path : '/hyperdrive' , root : true }
242
+ if ( path . startsWith ( this . _rootMnt ) && path !== this . _rootMnt ) {
243
+ const relativePath = path . slice ( this . _rootMnt . length )
244
+ if ( ! relativePath . startsWith ( '/home' ) ) throw new Error ( 'You can only mount sub-hyperdrives within the home directory.' )
245
+ return { path : relativePath , root : false }
246
+ }
247
+ }
248
+
239
249
async _driveForPath ( path , opts = { } ) {
250
+ console . error ( 'GETTING DRIVE FOR PATH:' , path )
240
251
return new Promise ( async ( resolve , reject ) => {
241
252
if ( ! this . _rootDrive ) {
253
+ console . log ( 'NO ROOT DRIVE' )
242
254
const drive = await this . driveManager . get ( opts . key , { ...opts , seed : false , configure : { rootDrive : true } } )
243
255
return resolve ( { drive, root : true } )
244
256
}
245
257
if ( path . startsWith ( this . _rootMnt ) && path !== this . _rootMnt ) {
246
258
const relativePath = path . slice ( this . _rootMnt . length )
247
259
if ( ! relativePath . startsWith ( '/home' ) ) throw new Error ( 'You can only mount sub-hyperdrives within the home directory.' )
248
260
261
+ console . error ( 'IT IS A SUBDRIVE, RELATIVE:' , relativePath )
249
262
return this . _rootDrive . readFile ( p . join ( relativePath , '.key' ) , ( err , key ) => {
250
263
if ( err && err . errno !== 2 ) return reject ( err )
251
264
key = key ? datEncoding . decode ( key . toString ( 'utf8' ) ) : opts . key
265
+ console . error ( 'KEY HERE:' , key , 'OPTS:' , opts )
252
266
return this . driveManager . get ( key , { ...opts , seed : ! ! opts . key } )
253
267
. then ( drive => resolve ( { drive, root : false , relativePath } ) )
254
268
. catch ( reject )
255
269
} )
256
270
}
271
+ console . error ( 'path:' , path , 'rootMnt:' , this . _rootMnt , 'claiming it is root' )
257
272
return resolve ( { drive : this . _rootDrive , root : true } )
258
273
} )
259
274
}
0 commit comments