From 1d3ab96728e057bcbf59f4f6cadf4ca1ff8cebbf Mon Sep 17 00:00:00 2001 From: "robertshield@chromium.org" Date: Tue, 11 May 2010 01:12:20 +0000 Subject: Try harder to clean up temp files in case we have a failed install / upgrade. BUG=37497 TEST=Fail an upgrade (for example, try to apply a differential installer to the wrong base version) while somehow endeavouring to lock the temp files mid upgrade (a debugger or a quick hand will be necessary) and observe that the temp files are scheduled for deletion on reboot. Review URL: http://codereview.chromium.org/1936006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46883 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/installer/setup/setup_main.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'chrome/installer') diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index 53d0918..c86a95a 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -24,6 +24,7 @@ #include "chrome/installer/setup/setup_util.h" #include "chrome/installer/setup/uninstall.h" #include "chrome/installer/util/browser_distribution.h" +#include "chrome/installer/util/delete_after_reboot_helper.h" #include "chrome/installer/util/delete_tree_work_item.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/html_dialog.h" @@ -373,7 +374,21 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line, installer_util::switches::kInstallerData); cleanup_list->AddDeleteTreeWorkItem(prefs_path, std::wstring()); } - cleanup_list->Do(); + + // The above cleanup has been observed to fail on several users machines. + // Specifically, it appears that the temp folder may be locked when we try + // to delete it. This is Rather Bad in the case where we have failed updates + // as we end up filling users' disks with large-ish temp files. To mitigate + // this, if we fail to delete the temp folders, then schedule them for + // deletion at next reboot. + if (!cleanup_list->Do()) { + ScheduleDirectoryForDeletion(temp_path.ToWStringHack().c_str()); + if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) { + std::wstring prefs_path = cmd_line.GetSwitchValue( + installer_util::switches::kInstallerData); + ScheduleDirectoryForDeletion(prefs_path.c_str()); + } + } dist->UpdateDiffInstallStatus(system_level, incremental_install, install_status); -- cgit v1.1