From f159cacfbb70bb3fd09126ca9e3372b5e2b448ef Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Wed, 20 Apr 2016 19:36:58 -0700 Subject: [PATCH] Use same timestamp for archive and config This fixes a very curious case: 1. App has backup. 2. App dies. 3. Box backs up. This make it reuse the backup. But it generates wrong config file timestamp. 4. Box cannot update anymore. This is because the backup of app fails - it tries to reuse the backup and that fails with AccessDenied because the timestamp above is wrong! --- src/backups.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backups.js b/src/backups.js index 17e512bdc..e1413c69f 100644 --- a/src/backups.js +++ b/src/backups.js @@ -189,8 +189,9 @@ function copyLastBackup(app, callback) { assert.strictEqual(typeof app.lastBackupId, 'string'); assert.strictEqual(typeof callback, 'function'); - var toFilenameArchive = util.format('appbackup_%s_%s-v%s.tar.gz', app.id, (new Date()).toISOString(), app.manifest.version); - var toFilenameConfig = util.format('appbackup_%s_%s-v%s.json', app.id, (new Date()).toISOString(), app.manifest.version); + var now = new Date(); + var toFilenameArchive = util.format('appbackup_%s_%s-v%s.tar.gz', app.id, now.toISOString(), app.manifest.version); + var toFilenameConfig = util.format('appbackup_%s_%s-v%s.json', app.id, now.toISOString(), app.manifest.version); settings.getBackupConfig(function (error, backupConfig) { if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error));