Add conditional that stops ancestors service from calling the same ownerUuid in infin...
[arvados-workbench2.git] / src / services / ancestors-service / ancestors-service.ts
index 44e4eef5c944b271eba16c558b43a4d700c4f886..697cd8fd246e5b4ae2d113f4f12c09195d34ca97 100644 (file)
@@ -14,7 +14,12 @@ export class AncestorService {
         private userService: UserService
     ) { }
 
-    async ancestors(uuid: string, rootUuid: string): Promise<Array<UserResource | GroupResource>> {
+    async ancestors(uuid: string, rootUuid: string, previousUuid = ''): Promise<Array<UserResource | GroupResource>> {
+
+        if (uuid === previousUuid) {
+            return [];
+        }
+
         const service = this.getService(extractUuidObjectType(uuid));
         if (service) {
             try {
@@ -23,7 +28,7 @@ export class AncestorService {
                     return [resource];
                 } else {
                     return [
-                        ...await this.ancestors(resource.ownerUuid, rootUuid),
+                        ...await this.ancestors(resource.ownerUuid, rootUuid, uuid),
                         resource
                     ];
                 }