Skip to content

Commit cb0bdbd

Browse files
committed
Depend on client-side package installation root (#28)
1 parent dfead97 commit cb0bdbd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/packages.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,16 @@ class Packages {
156156
* @param {object} user
157157
*/
158158
async installPackage(url, options, user) {
159+
if (!options.root) {
160+
throw new Error('Missing package installation root path');
161+
}
162+
159163
const {realpath} = this.core.make('osjs/vfs');
160164

161165
const name = path.basename(url.split('?')[0])
162166
.replace(/\.[^/.]+$/, '');
163167

164-
const userRoot = options.root || 'home:/.packages'; // FIXME: Client-side
168+
const userRoot = options.root;
165169
const target = await realpath(`${userRoot}/${name}`, user);
166170
const root = await realpath(userRoot, user);
167171
const manifest = await realpath(`${userRoot}/metadata.json`, user);
@@ -194,6 +198,10 @@ class Packages {
194198
const metadatas = await Promise.all(filenames.map(f => fs.readJson(f)));
195199

196200
await fs.writeJson(manifest, metadatas);
201+
202+
return {
203+
reload: !options.system
204+
};
197205
}
198206

199207
/**

src/providers/packages.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class PackageServiceProvider extends ServiceProvider {
8080

8181
routeAuthenticated('POST', '/api/packages/install', (req, res) => {
8282
this.packages.installPackage(req.body.url, req.body.options, req.session.user)
83-
.then(() => res.json({success: true}))
83+
.then(body => res.json(body))
8484
.catch((error) => {
8585
console.error(error);
8686
res.status(400).json({error: 'Package installation failed'});

0 commit comments

Comments
 (0)