Skip to content

Commit 281c631

Browse files
mahsashadimahsa shadi
and
mahsa shadi
authored
Add VFS capabilities method (#65)
Co-authored-by: mahsa shadi <[email protected]>
1 parent 255419e commit 281c631

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

__tests__/adapters/vfs/system.js

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ describe('VFS System adapter', () => {
3535

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

38+
test('#capabilities', () => {
39+
return expect(request('capabilities', '', createOptions()))
40+
.resolves
41+
.toMatchObject({
42+
pagination: false,
43+
sort: false,
44+
});
45+
});
46+
3847
test('#touch', () => {
3948
return expect(request('touch', 'home:/test', createOptions()))
4049
.resolves

src/adapters/vfs/system.js

+12
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ module.exports = (core) => {
163163
return watch;
164164
},
165165

166+
/**
167+
* Get filesystem capabilities
168+
* @param {String} file The file path from client
169+
* @param {Object} [options={}] Options
170+
* @return {Object[]}
171+
*/
172+
capabilities: vfs => (file, options = {}) =>
173+
Promise.resolve({
174+
sort: false,
175+
pagination: false
176+
}),
177+
166178
/**
167179
* Checks if file exists
168180
* @param {String} file The file path from client

src/vfs.js

+2
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ const vfs = core => {
235235

236236
// Wire up all available VFS events
237237
return {
238+
capabilities: createRequest(requestPath, 'capabilities', false),
238239
realpath: createRequest(requestPath, 'realpath', false),
239240
exists: createRequest(requestPath, 'exists', false, respondBoolean),
240241
stat: createRequest(requestPath, 'stat', false),
@@ -266,6 +267,7 @@ module.exports = core => {
266267
router.use(middleware);
267268

268269
// Then all VFS routes (needs implementation above)
270+
router.get('/capabilities', wrapper(methods.capabilities));
269271
router.get('/exists', wrapper(methods.exists));
270272
router.get('/stat', wrapper(methods.stat));
271273
router.get('/readdir', wrapper(methods.readdir));

0 commit comments

Comments
 (0)