Skip to content

Commit de62323

Browse files
committed
Bug fixes
1 parent 37438e3 commit de62323

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

index.js

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ class Hypermount {
4646
force: true,
4747
displayFolder: true
4848
})
49+
await this.db.put(mnt, {
50+
...opts,
51+
key: mountInfo.key,
52+
mnt
53+
})
4954
this.drives.set(mountInfo.key, drive)
5055

51-
return mountInfo
56+
return mountInfo.key
5257
}
5358

5459
unmount (mnt) {
@@ -59,25 +64,10 @@ class Hypermount {
5964
return this.store.close()
6065
}
6166

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-
7467
async unmount (mnt) {
75-
await this.unmount(mnt)
76-
7768
let record = await this.db.get(mnt)
7869
if (!record) return
79-
80-
await this.db.put(mnt, record)
70+
await hyperfuse.unmount(mnt)
8171
}
8272

8373
unmountAll () {
@@ -140,7 +130,7 @@ class Hypermount {
140130
}
141131
}
142132

143-
function bindRoutes (app, hypermount) {
133+
function bindRoutes (app, metadata, hypermount, cleanup) {
144134
app.use(express.json())
145135
app.use((req, res, next) => {
146136
if (!req.headers.authorization) return res.sendStatus(403)
@@ -154,7 +144,6 @@ function bindRoutes (app, hypermount) {
154144
key = await hypermount.mount(key, mnt, req.body)
155145
return res.status(201).json({ key, mnt })
156146
} catch (err) {
157-
console.error('Mount error:', err)
158147
return res.sendStatus(500)
159148
}
160149
})
@@ -163,10 +152,8 @@ function bindRoutes (app, hypermount) {
163152
try {
164153
const mnt = req.body.mnt
165154
await hypermount.unmount(mnt)
166-
167155
return res.sendStatus(200)
168156
} catch (err) {
169-
console.error('Unmount error:', err)
170157
return res.sendStatus(500)
171158
}
172159
})
@@ -175,8 +162,8 @@ function bindRoutes (app, hypermount) {
175162
try {
176163
await cleanup()
177164
res.sendStatus(200)
165+
process.exit(0)
178166
} catch (err) {
179-
console.error('Close error:', err)
180167
return res.sendStatus(500)
181168
}
182169
})
@@ -190,7 +177,6 @@ function bindRoutes (app, hypermount) {
190177
let result = await hypermount.list()
191178
return res.json(result)
192179
} catch (err) {
193-
console.error('List error:', err)
194180
return res.sendStatus(500)
195181
}
196182
})
@@ -223,7 +209,7 @@ async function start () {
223209
await hypermount.ready()
224210
await hypermount.refreshMounts()
225211

226-
bindRoutes(app, hypermount)
212+
bindRoutes(app, metadata, hypermount, cleanup)
227213
var server = app.listen(argv.port || 3005)
228214

229215
process.once('SIGINT', cleanup)

0 commit comments

Comments
 (0)