Skip to content

Commit

Permalink
Support async adapter functions (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Jul 22, 2020
1 parent 1b07738 commit 41f1cad
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/utils/vfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,20 @@ const createError = (code, message) => {
/**
* Resolves a mountpoint
*/
const mountpointResolver = core => (path) => {
const mountpointResolver = core => async (path) => {
const {adapters, mountpoints} = core.make('osjs/vfs');
const prefix = getPrefix(path);
const mount = mountpoints.find(m => m.name === prefix);

if (mount) {
const adapter = mount.adapter
? adapters[mount.adapter]
: adapters.system;

return Promise.resolve({mount, adapter});
if (!mount) {
throw createError(403, `Mountpoint not found for '${prefix}'`);
}

return Promise.reject(createError(403, `Mountpoint not found for '${prefix}'`));
const adapter = await (mount.adapter
? adapters[mount.adapter]
: adapters.system);

return {mount, adapter};
};

/*
Expand Down

0 comments on commit 41f1cad

Please sign in to comment.