Skip to content

Commit

Permalink
Add VFS capabilities method
Browse files Browse the repository at this point in the history
  • Loading branch information
mahsa shadi committed Jul 31, 2022
1 parent 65dfdd5 commit 069161d
Show file tree
Hide file tree
Showing 3 changed files with 22 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
11 changes: 11 additions & 0 deletions src/adapters/vfs/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ 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
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 069161d

Please sign in to comment.