[ARVADOS-WORKBENCH2] updated: 2.1.0-127-gd71b173b

Git user git at public.arvados.org
Fri Dec 4 22:40:21 UTC 2020


Summary of changes:
 .../collection-service/collection-service.ts       | 24 +++++++++-------------
 1 file changed, 10 insertions(+), 14 deletions(-)

       via  d71b173b8d2b64dcb4d7bcfda05dd28e85f2dad0 (commit)
      from  84dd7a887671e3fb01afcdb832942c22dc48cf82 (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 d71b173b8d2b64dcb4d7bcfda05dd28e85f2dad0
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date:   Fri Dec 4 19:38:10 2020 -0300

    17152: Changes the preserve_version set order to avoid fake modified_at.
    
    As the create() method already sets preserve_version to true, it's better
    to re-set it to true after each update, so that the modified_at timestamp
    of the previous version doesn't change.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>

diff --git a/src/services/collection-service/collection-service.ts b/src/services/collection-service/collection-service.ts
index 73e0a667..3280d05e 100644
--- a/src/services/collection-service/collection-service.ts
+++ b/src/services/collection-service/collection-service.ts
@@ -32,11 +32,11 @@ export class CollectionService extends TrashableResourceService<CollectionResour
     }
 
     async update(uuid: string, data: Partial<CollectionResource>) {
-        // First set head version to be preserved
-        const collection = await super.update(uuid, { preserveVersion: true });
+        // First make the changes
+        const collection = await super.update(uuid, data);
         if (data === { preserveVersion: true }) { return collection; }
-        // Then make changes
-        return await super.update(uuid, data);
+        // Then set the head version to be preserved
+        return await super.update(uuid, { preserveVersion: true });
     }
 
     async files(uuid: string) {
@@ -48,9 +48,7 @@ export class CollectionService extends TrashableResourceService<CollectionResour
     }
 
     async deleteFiles(collectionUuid: string, filePaths: string[]) {
-        if (collectionUuid !== "" && filePaths.length > 0) {
-            await this.update(collectionUuid, { preserveVersion: true });
-        }
+        if (collectionUuid === "" || filePaths.length === 0) { return; }
         for (const path of filePaths) {
             const splittedPath = path.split('/');
             if (collectionUuid) {
@@ -59,26 +57,24 @@ export class CollectionService extends TrashableResourceService<CollectionResour
                 await this.webdavClient.delete(`c=${collectionUuid}${path}`);
             }
         }
+        await this.update(collectionUuid, { preserveVersion: true });
     }
 
     async uploadFiles(collectionUuid: string, files: File[], onProgress?: UploadProgress) {
-        if (collectionUuid !== "" && files.length > 0) {
-            await this.update(collectionUuid, { preserveVersion: true });
-        }
+        if (collectionUuid === "" || files.length === 0) { return; }
         // files have to be uploaded sequentially
         for (let idx = 0; idx < files.length; idx++) {
             await this.uploadFile(collectionUuid, files[idx], idx, onProgress);
         }
+        await this.update(collectionUuid, { preserveVersion: true });
     }
 
     async moveFile(collectionUuid: string, oldPath: string, newPath: string) {
-        if (collectionUuid !== "") {
-            await this.update(collectionUuid, { preserveVersion: true });
-        }
-        return this.webdavClient.move(
+        await this.webdavClient.move(
             `c=${collectionUuid}${oldPath}`,
             `c=${collectionUuid}${encodeURI(newPath)}`
         );
+        return await this.update(collectionUuid, { preserveVersion: true });
     }
 
     extendFileURL = (file: CollectionDirectory | CollectionFile) => {

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list