[ARVADOS-WORKBENCH2] updated: 1.1.4-525-gbe4d5a9

Git user git at public.curoverse.com
Mon Aug 6 08:46:51 EDT 2018


Summary of changes:
 .../collection-files-service.ts                    | 38 ++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

       via  be4d5a950e31200e907cd379cf9210a7c3dd8643 (commit)
      from  905f260842e2863ca42d27fcefcfa94d1cc45267 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit be4d5a950e31200e907cd379cf9210a7c3dd8643
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Mon Aug 6 14:46:28 2018 +0200

    Implement renameFile and deleteFile [WIP]
    
    Feature #13967
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/services/collection-files-service/collection-files-service.ts b/src/services/collection-files-service/collection-files-service.ts
index 96c9e99..3b320eb 100644
--- a/src/services/collection-files-service/collection-files-service.ts
+++ b/src/services/collection-files-service/collection-files-service.ts
@@ -3,11 +3,12 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { CollectionService } from "../collection-service/collection-service";
-import { parseKeepManifestText } from "./collection-manifest-parser";
+import { parseKeepManifestText, stringifyKeepManifest } from "./collection-manifest-parser";
 import { mapManifestToCollectionFilesTree } from "./collection-manifest-mapper";
+import { CollectionFile } from "../../models/collection-file";
 
 export class CollectionFilesService {
-    
+
     constructor(private collectionService: CollectionService) { }
 
     getFiles(collectionUuid: string) {
@@ -22,4 +23,37 @@ export class CollectionFilesService {
             );
     }
 
+    async renameFile(collectionUuid: string, file: { name: string, path: string }, newName: string) {
+        const collection = await this.collectionService.get(collectionUuid);
+        const manifest = parseKeepManifestText(collection.manifestText);
+        const updatedManifest = manifest.map(stream =>
+            stream.name === file.path
+                ? {
+                    ...stream,
+                    files: stream.files.map(f =>
+                        f.name === file.name
+                            ? { ...f, name: newName }
+                            : f)
+                }
+                : stream
+        );
+        const manifestText = stringifyKeepManifest(updatedManifest);
+        return this.collectionService.update(collectionUuid, { ...collection, manifestText });
+    }
+
+    async deleteFile(collectionUuid: string, file: { name: string, path: string }) {
+        const collection = await this.collectionService.get(collectionUuid);
+        const manifest = parseKeepManifestText(collection.manifestText);
+        const updatedManifest = manifest.map(stream =>
+            stream.name === file.path
+                ? {
+                    ...stream,
+                    files: stream.files.filter(f => f.name !== file.name)
+                }
+                : stream
+        );
+        const manifestText = stringifyKeepManifest(updatedManifest);
+        return this.collectionService.update(collectionUuid, { manifestText });
+    }
+
 }
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list