@@ -24,6 +24,7 @@ class ACLChecker {
2424 this . suffix = options . suffix || DEFAULT_ACL_SUFFIX
2525 this . aclCached = { }
2626 this . messagesCached = { }
27+ this . requests = { }
2728 }
2829
2930 // Returns a fulfilled promise when the user can access the resource
@@ -139,7 +140,8 @@ class ACLChecker {
139140 const acl = possibleACLs . shift ( )
140141 let graph
141142 try {
142- graph = await this . fetch ( acl )
143+ this . requests [ acl ] = this . requests [ acl ] || this . fetch ( acl )
144+ graph = await this . requests [ acl ]
143145 } catch ( err ) {
144146 if ( err && ( err . code === 'ENOENT' || err . status === 404 ) ) {
145147 isContainer = true
@@ -157,8 +159,13 @@ class ACLChecker {
157159 throw new HTTPError ( 500 , `No ACL found for ${ resource } , searched in \n- ${ acls . join ( '\n- ' ) } ` )
158160 }
159161 console . log ( '>>>> GRAPH WITHOUT GROUPS' , returnAcl . graph . length )
160- const groupUrls = returnAcl . graph . statementsMatching ( null , ACL ( 'agentGroup' ) , null ) . map ( node => node . object . value . split ( '#' ) [ 0 ] )
161- await Promise . all ( groupUrls . map ( groupUrl => this . fetch ( groupUrl , returnAcl . graph ) ) )
162+ const groupUrls = returnAcl . graph
163+ . statementsMatching ( null , ACL ( 'agentGroup' ) , null )
164+ . map ( node => node . object . value )
165+ await Promise . all ( groupUrls . map ( groupUrl => {
166+ this . requests [ groupUrl ] = this . requests [ groupUrl ] || this . fetch ( groupUrl , returnAcl . graph )
167+ return this . requests [ groupUrl ]
168+ } ) )
162169 console . log ( '>>>> GRAPH WITH GROUPS' , returnAcl . graph . length )
163170
164171 return returnAcl
0 commit comments