aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/filelist.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/filelist.js')
-rw-r--r--apps/files/js/filelist.js47
1 files changed, 43 insertions, 4 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index 8b12cce51d1..9459a266ce9 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -989,7 +989,7 @@
});
}
- this.move(_.pluck(files, 'name'), targetPath);
+ var movePromise = this.move(_.pluck(files, 'name'), targetPath);
// re-enable td elements to be droppable
// sometimes the filename drop handler is still called after re-enable,
@@ -997,6 +997,8 @@
setTimeout(function() {
self.$el.find('td.filename.ui-droppable').droppable('enable');
}, 10);
+
+ return movePromise;
},
/**
@@ -2162,7 +2164,31 @@
if (!_.isArray(fileNames)) {
fileNames = [fileNames];
}
- _.each(fileNames, function(fileName) {
+
+ function Semaphore(max) {
+ var counter = 0;
+ var waiting = [];
+
+ this.acquire = function() {
+ if(counter < max) {
+ counter++;
+ return new Promise(function(resolve) { resolve(); });
+ } else {
+ return new Promise(function(resolve) { waiting.push(resolve); });
+ }
+ };
+
+ this.release = function() {
+ counter--;
+ if (waiting.length > 0 && counter < max) {
+ counter++;
+ var promise = waiting.shift();
+ promise();
+ }
+ };
+ }
+
+ var moveFileFunction = function(fileName) {
var $tr = self.findFileEl(fileName);
self.showFileBusyState($tr, true);
if (targetPath.charAt(targetPath.length - 1) !== '/') {
@@ -2170,7 +2196,7 @@
// not overwrite it
targetPath = targetPath + '/';
}
- self.filesClient.move(dir + fileName, targetPath + fileName)
+ return self.filesClient.move(dir + fileName, targetPath + fileName)
.done(function() {
// if still viewing the same directory
if (OC.joinPaths(self.getCurrentDirectory(), '/') === dir) {
@@ -2201,11 +2227,24 @@
.always(function() {
self.showFileBusyState($tr, false);
});
+ };
+
+ var mcSemaphore = new Semaphore(10);
+ var counter = 0;
+ var promises = _.map(fileNames, function(arg) {
+ return mcSemaphore.acquire().then(function(){
+ moveFileFunction(arg).then(function(){
+ mcSemaphore.release();
+ counter++;
+ });
+ });
+ });
+
+ return Promise.all(promises).then(function(){
if (callback) {
callback();
}
});
-
},
/**