diff --git a/src/packages.js b/src/packages.js index a857045..9ff4d46 100644 --- a/src/packages.js +++ b/src/packages.js @@ -156,12 +156,16 @@ class Packages { * @param {object} user */ async installPackage(url, options, user) { + if (!options.root) { + throw new Error('Missing package installation root path'); + } + const {realpath} = this.core.make('osjs/vfs'); const name = path.basename(url.split('?')[0]) .replace(/\.[^/.]+$/, ''); - const userRoot = options.root || 'home:/.packages'; // FIXME: Client-side + const userRoot = options.root; const target = await realpath(`${userRoot}/${name}`, user); const root = await realpath(userRoot, user); const manifest = await realpath(`${userRoot}/metadata.json`, user); @@ -194,6 +198,10 @@ class Packages { const metadatas = await Promise.all(filenames.map(f => fs.readJson(f))); await fs.writeJson(manifest, metadatas); + + return { + reload: !options.system + }; } /** diff --git a/src/providers/packages.js b/src/providers/packages.js index 31afff3..6845bec 100644 --- a/src/providers/packages.js +++ b/src/providers/packages.js @@ -80,7 +80,7 @@ class PackageServiceProvider extends ServiceProvider { routeAuthenticated('POST', '/api/packages/install', (req, res) => { this.packages.installPackage(req.body.url, req.body.options, req.session.user) - .then(() => res.json({success: true})) + .then(body => res.json(body)) .catch((error) => { console.error(error); res.status(400).json({error: 'Package installation failed'});