@@ -46,9 +46,14 @@ class Hypermount {
46
46
force : true ,
47
47
displayFolder : true
48
48
} )
49
+ await this . db . put ( mnt , {
50
+ ...opts ,
51
+ key : mountInfo . key ,
52
+ mnt
53
+ } )
49
54
this . drives . set ( mountInfo . key , drive )
50
55
51
- return mountInfo
56
+ return mountInfo . key
52
57
}
53
58
54
59
unmount ( mnt ) {
@@ -59,25 +64,10 @@ class Hypermount {
59
64
return this . store . close ( )
60
65
}
61
66
62
- async mount ( key , mnt , opts ) {
63
- let { key : mountedKey } = await this . mount ( key , mnt , opts )
64
-
65
- await this . db . put ( mnt , {
66
- ...opts ,
67
- key : mountedKey ,
68
- mnt
69
- } )
70
-
71
- return mountedKey
72
- }
73
-
74
67
async unmount ( mnt ) {
75
- await this . unmount ( mnt )
76
-
77
68
let record = await this . db . get ( mnt )
78
69
if ( ! record ) return
79
-
80
- await this . db . put ( mnt , record )
70
+ await hyperfuse . unmount ( mnt )
81
71
}
82
72
83
73
unmountAll ( ) {
@@ -140,7 +130,7 @@ class Hypermount {
140
130
}
141
131
}
142
132
143
- function bindRoutes ( app , hypermount ) {
133
+ function bindRoutes ( app , metadata , hypermount , cleanup ) {
144
134
app . use ( express . json ( ) )
145
135
app . use ( ( req , res , next ) => {
146
136
if ( ! req . headers . authorization ) return res . sendStatus ( 403 )
@@ -154,7 +144,6 @@ function bindRoutes (app, hypermount) {
154
144
key = await hypermount . mount ( key , mnt , req . body )
155
145
return res . status ( 201 ) . json ( { key, mnt } )
156
146
} catch ( err ) {
157
- console . error ( 'Mount error:' , err )
158
147
return res . sendStatus ( 500 )
159
148
}
160
149
} )
@@ -163,10 +152,8 @@ function bindRoutes (app, hypermount) {
163
152
try {
164
153
const mnt = req . body . mnt
165
154
await hypermount . unmount ( mnt )
166
-
167
155
return res . sendStatus ( 200 )
168
156
} catch ( err ) {
169
- console . error ( 'Unmount error:' , err )
170
157
return res . sendStatus ( 500 )
171
158
}
172
159
} )
@@ -175,8 +162,8 @@ function bindRoutes (app, hypermount) {
175
162
try {
176
163
await cleanup ( )
177
164
res . sendStatus ( 200 )
165
+ process . exit ( 0 )
178
166
} catch ( err ) {
179
- console . error ( 'Close error:' , err )
180
167
return res . sendStatus ( 500 )
181
168
}
182
169
} )
@@ -190,7 +177,6 @@ function bindRoutes (app, hypermount) {
190
177
let result = await hypermount . list ( )
191
178
return res . json ( result )
192
179
} catch ( err ) {
193
- console . error ( 'List error:' , err )
194
180
return res . sendStatus ( 500 )
195
181
}
196
182
} )
@@ -223,7 +209,7 @@ async function start () {
223
209
await hypermount . ready ( )
224
210
await hypermount . refreshMounts ( )
225
211
226
- bindRoutes ( app , hypermount )
212
+ bindRoutes ( app , metadata , hypermount , cleanup )
227
213
var server = app . listen ( argv . port || 3005 )
228
214
229
215
process . once ( 'SIGINT' , cleanup )
0 commit comments