[ARVADOS] updated: e320b9009a294a81a68e56e1998782c445d1affe

git at public.curoverse.com git at public.curoverse.com
Thu Dec 4 16:24:45 EST 2014


Summary of changes:
 .../app/assets/javascripts/upload_to_collection.js | 32 ++++++++++------------
 1 file changed, 14 insertions(+), 18 deletions(-)

       via  e320b9009a294a81a68e56e1998782c445d1affe (commit)
      from  caf3ebfb538efbfc0b2e3b360186d68bdb78b744 (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 e320b9009a294a81a68e56e1998782c445d1affe
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Dec 4 16:24:55 2014 -0500

    3781: Fix push-to-bottom-when-Done so it works on the last item, too.

diff --git a/apps/workbench/app/assets/javascripts/upload_to_collection.js b/apps/workbench/app/assets/javascripts/upload_to_collection.js
index 5e93d4e..4ca5df6 100644
--- a/apps/workbench/app/assets/javascripts/upload_to_collection.js
+++ b/apps/workbench/app/assets/javascripts/upload_to_collection.js
@@ -345,29 +345,16 @@ function UploadToCollection($scope, $filter, $q, $timeout,
             return doQueueWork();
         }
         function doQueueWork() {
-            var nItemsDone;
             that.state = 'Running';
             that.stateReason = null;
-            // Are there any Done things at the top of the queue?
-            for (nItemsDone = 0;
-                 (nItemsDone < $scope.uploadQueue.length &&
-                  $scope.uploadQueue[nItemsDone].state === 'Done'); ) {
-                nItemsDone++;
-            }
-            // If so, push them down to the bottom of the queue.
-            if (nItemsDone > 0) {
-                $scope.uploadQueue.push.apply(
-                    $scope.uploadQueue,
-                    $scope.uploadQueue.splice(0, nItemsDone));
-            }
-            // If anything is not-done, do it.
+            // If anything is not Done, do it.
             if ($scope.uploadQueue.length > 0 &&
                 $scope.uploadQueue[0].state !== 'Done') {
                 return $scope.uploadQueue[0].go().
                     then(appendToCollection, null, onQueueProgress).
                     then(doQueueWork, onQueueReject);
             }
-            // If everything is done, resolve the promise and clean up.
+            // If everything is Done, resolve the promise and clean up.
             return onQueueResolve();
         }
         function onQueueReject(reason) {
@@ -420,9 +407,18 @@ function UploadToCollection($scope, $filter, $q, $timeout,
                         }).
                         then(deferred.resolve);
                 }, onQueueReject).then(function() {
-                    $.each(uploads, function(_, upload) {
-                        upload.committed = true;
-                    });
+                    // Push the completed upload(s) to the bottom of the queue.
+                    var i, qLen = $scope.uploadQueue.length;
+                    for (i=0; i<qLen; i++) {
+                        if (uploads.indexOf($scope.uploadQueue[i]) >= 0) {
+                            $scope.uploadQueue[i].committed = true;
+                            $scope.uploadQueue.push.apply(
+                                $scope.uploadQueue,
+                                $scope.uploadQueue.splice(i, 1));
+                            --i;
+                            --qLen;
+                        }
+                    }
                 });
             return deferred.promise.then(doQueueWork);
         }

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list