Skip to content
Merged
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
16 changes: 14 additions & 2 deletions src/vfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ import {
* @property {object} [stat]
*/

// Cache the capability of each mount point
let capabilityCache = {};

// Makes sure our input paths are object(s)
const pathToObject = path => ({
id: null,
Expand All @@ -81,8 +84,17 @@ const handleDirectoryList = (path, options) => result =>
* @param {VFSMethodOptions} [options] Options
* @return {Promise<object[]>} An object of capabilities
*/
export const capabilities = (adapter, mount) => (path, options = {}) =>
adapter.capabilities(pathToObject(path), options, mount);
export const capabilities = (adapter, mount) => (path, options = {}) => {
const cached = capabilityCache[mount.name];
if (cached) {
return Promise.resolve(cached);
}
return adapter.capabilities(pathToObject(path), options, mount)
.then(res => {
capabilityCache[mount.name] = res;
return res;
});
};


/**
Expand Down