diff --git a/src/storage/s3.js b/src/storage/s3.js index c4c6d39ec..4693cfca3 100644 --- a/src/storage/s3.js +++ b/src/storage/s3.js @@ -239,13 +239,13 @@ function copy(apiConfig, oldFilePath, newFilePath, callback) { var copyParams = { Bucket: apiConfig.bucket, Key: path.join(newFilePath, relativePath), - CopySource: path.join(apiConfig.bucket, content.Key) + CopySource: encodeURIComponent(path.join(apiConfig.bucket, content.Key)) // See aws-sdk-js/issues/1302 }; progress.setDetail(progress.BACKUP, 'Copying ' + content.Key.slice(oldFilePath.length+1)); s3.copyObject(copyParams, function (error) { - if (error && error.code === 'NoSuchKey') return iteratorCallback(new BackupsError(BackupsError.NOT_FOUND, `Old backup ${content.Key} not found`)); + if (error && error.code === 'NoSuchKey') return iteratorCallback(new BackupsError(BackupsError.NOT_FOUND, `Old backup not found: ${content.Key}`)); if (error) { debug('copy: s3 copy error.', error); return iteratorCallback(new BackupsError(BackupsError.EXTERNAL_ERROR, `Error copying ${content.Key} : ${error.message}`)); diff --git a/src/test/storage-test.js b/src/test/storage-test.js index 08d595d9d..df3b15797 100644 --- a/src/test/storage-test.js +++ b/src/test/storage-test.js @@ -252,12 +252,17 @@ describe('Storage', function () { }); it('can copy', function (done) { + fs.writeFileSync(path.join(gS3Folder, 'uploadtest/C++.gitignore'), 'special', 'utf8'); + var sourceKey = 'uploadtest'; s3.copy(gBackupConfig, sourceKey, 'uploadtest-copy', function (error) { var sourceFile = path.join(__dirname, 'storage/data/test.txt'); expect(error).to.be(null); expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/test.txt')).size).to.be(fs.statSync(sourceFile).size); + + expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/C++.gitignore')).size).to.be(7); + done(); }); });