Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VFS capabilities method #65

Merged
merged 2 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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({
andersevenrud marked this conversation as resolved.
Show resolved Hide resolved
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