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 {
60
60
* @property {object } [stat]
61
61
*/
62
62
63
+ // Cache the capability of each mount point
64
+ let capabilityCache = { } ;
65
+
63
66
// Makes sure our input paths are object(s)
64
67
const pathToObject = path => ( {
65
68
id : null ,
@@ -81,8 +84,17 @@ const handleDirectoryList = (path, options) => result =>
81
84
* @param {VFSMethodOptions } [options] Options
82
85
* @return {Promise<object[]> } An object of capabilities
83
86
*/
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
+ } ;
86
98
87
99
88
100
/**
You can’t perform that action at this time.
0 commit comments