diff --git a/tasks/cloudfiles.js b/tasks/cloudfiles.js index 272d872..34e2a9b 100644 --- a/tasks/cloudfiles.js +++ b/tasks/cloudfiles.js @@ -101,9 +101,31 @@ module.exports = function(grunt) { if (upload.dest === undefined) { upload.dest = '' } + var maxAttemptsPerFile = 5; + async.forEachLimit(files, 10, function(file, next) { + + var attempt = 1; + + var onSyncFile = function(err) { + if(err) { + grunt.log.writeln('Error syncing file: ' + file + ' to ' + container.name + ', attempt: ' + attempt + '/' + maxAttemptsPerFile); + + attempt++; + + if(attempt < maxAttemptsPerFile) { + syncFile(file, container, upload.dest, upload.stripcomponents, upload.headers, onSyncFile); + } else { + next(err); + } + + } else { + next(); + } + } + if (grunt.file.isFile(file)) { - syncFile(file, container, upload.dest, upload.stripcomponents, upload.headers, next); + syncFile(file, container, upload.dest, upload.stripcomponents, upload.headers, onSyncFile); } else { next();