Skip to content

Commit

Permalink
Add VFS capabilities method (#65)
Browse files Browse the repository at this point in the history
Co-authored-by: mahsa shadi <mahsa.shadi@mail.um.ac.ir>
  • Loading branch information
mahsashadi and mahsa shadi committed Aug 1, 2022
1 parent 255419e commit 281c631
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions __tests__/adapters/vfs/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ describe('VFS System adapter', () => {

const request = (name, ...args) => adapter[name](vfs, vfs)(...args);

test('#capabilities', () => {
return expect(request('capabilities', '', createOptions()))
.resolves
.toMatchObject({
pagination: false,
sort: false,
});
});

test('#touch', () => {
return expect(request('touch', 'home:/test', createOptions()))
.resolves
Expand Down
12 changes: 12 additions & 0 deletions src/adapters/vfs/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ module.exports = (core) => {
return watch;
},

/**
* Get filesystem capabilities
* @param {String} file The file path from client
* @param {Object} [options={}] Options
* @return {Object[]}
*/
capabilities: vfs => (file, options = {}) =>
Promise.resolve({
sort: false,
pagination: false
}),

/**
* Checks if file exists
* @param {String} file The file path from client
Expand Down
2 changes: 2 additions & 0 deletions src/vfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const vfs = core => {

// Wire up all available VFS events
return {
capabilities: createRequest(requestPath, 'capabilities', false),
realpath: createRequest(requestPath, 'realpath', false),
exists: createRequest(requestPath, 'exists', false, respondBoolean),
stat: createRequest(requestPath, 'stat', false),
Expand Down Expand Up @@ -266,6 +267,7 @@ module.exports = core => {
router.use(middleware);

// Then all VFS routes (needs implementation above)
router.get('/capabilities', wrapper(methods.capabilities));
router.get('/exists', wrapper(methods.exists));
router.get('/stat', wrapper(methods.stat));
router.get('/readdir', wrapper(methods.readdir));
Expand Down

0 comments on commit 281c631

Please sign in to comment.