File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,9 @@ import {
6060 * @property {object } [stat]
6161 */
6262
63+ // Cache the capability of each mount point
64+ let capabilityCache = { } ;
65+
6366// Makes sure our input paths are object(s)
6467const pathToObject = path => ( {
6568 id : null ,
@@ -81,8 +84,17 @@ const handleDirectoryList = (path, options) => result =>
8184 * @param {VFSMethodOptions } [options] Options
8285 * @return {Promise<object[]> } An object of capabilities
8386 */
84- export const capabilities = ( adapter , mount ) => ( path , options = { } ) =>
85- adapter . capabilities ( pathToObject ( path ) , options , mount ) ;
87+ export const capabilities = ( adapter , mount ) => ( path , options = { } ) => {
88+ const cached = capabilityCache [ mount . name ] ;
89+ if ( cached ) {
90+ return Promise . resolve ( cached ) ;
91+ }
92+ return adapter . capabilities ( pathToObject ( path ) , options , mount )
93+ . then ( res => {
94+ capabilityCache [ mount . name ] = res ;
95+ return res ;
96+ } ) ;
97+ } ;
8698
8799
88100/**
You can’t perform that action at this time.
0 commit comments