From ef9d942e8bd159f3b7e9ab2b5009420201759afe Mon Sep 17 00:00:00 2001 From: Robert Strong Date: Thu, 27 Aug 2009 22:25:35 -0700 Subject: [PATCH] Bug 470979 - Keep a copy of the last-update.log renamed when the partial fails for troubleshooting. r=dtownsend --- .../mozapps/update/src/nsUpdateService.js.in | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/toolkit/mozapps/update/src/nsUpdateService.js.in b/toolkit/mozapps/update/src/nsUpdateService.js.in index aa2efc967c5..b6f7bf2e1b3 100644 --- a/toolkit/mozapps/update/src/nsUpdateService.js.in +++ b/toolkit/mozapps/update/src/nsUpdateService.js.in @@ -95,6 +95,7 @@ const FILE_UPDATES_DB = "updates.xml"; const FILE_UPDATE_ACTIVE = "active-update.xml"; const FILE_PERMS_TEST = "update.test"; const FILE_LAST_LOG = "last-update.log"; +const FILE_BACKUP_LOG = "backup-update.log"; const FILE_UPDATE_LOCALE = "update.locale"; const MODE_RDONLY = 0x01; @@ -457,12 +458,21 @@ function cleanUpUpdatesDir(key) { var dir = f.parent.parent; var logFile = dir.clone(); logFile.append(FILE_LAST_LOG); - if (logFile.exists()) - logFile.remove(false); - f.copyTo(dir, FILE_LAST_LOG); + if (logFile.exists()) { + try { + logFile.moveTo(dir, FILE_BACKUP_LOG); + } + catch (e) { + LOG("General", "cleanUpUpdatesDir - failed to rename file " + + logFile.path + " to " + FILE_BACKUP_LOG); + } + } + f.moveTo(dir, FILE_LAST_LOG); + continue; } catch (e) { - LOG("General", "cleanUpUpdatesDir - failed to copy file: " + f.path); + LOG("General", "cleanUpUpdatesDir - failed to move file " + f.path + + " to " + dir.path + " and rename it to " + FILE_LAST_LOG); } } // Now, recursively remove this file. The recusive removal is really @@ -472,7 +482,7 @@ function cleanUpUpdatesDir(key) { f.remove(true); } catch (e) { - LOG("General", "cleanUpUpdatesDir - failed to remove file: " + f.path); + LOG("General", "cleanUpUpdatesDir - failed to remove file " + f.path); } } try {