Delete chrome.7z archives in the current installation when doing an upgrade t... (issue6683005)

4,638 views
Skip to first unread message

g...@chromium.org

unread,
Mar 11, 2011, 4:03:15 PM3/11/11
to to...@chromium.org, robert...@chromium.org, chromium...@chromium.org
Reviewers: tommi, robertshield,

Description:
Delete chrome.7z archives in the current installation when doing an upgrade
to
save some disk space.

BUG=none
TEST=do an upgrade and see that the chrome.7z in the old version folder is
gone.


Please review this at http://codereview.chromium.org/6683005/

SVN Base: svn://svn.chromium.org/chrome/trunk/src/

Affected files:
M chrome/installer/setup/install_worker.cc
M chrome/installer/util/delete_tree_work_item.cc


Index: chrome/installer/setup/install_worker.cc
===================================================================
--- chrome/installer/setup/install_worker.cc (revision 77831)
+++ chrome/installer/setup/install_worker.cc (working copy)
@@ -488,10 +488,20 @@
install_list->AddCreateDirWorkItem(temp_path);
install_list->AddCreateDirWorkItem(target_path);

+ if (current_version != NULL && current_version->get() != NULL) {
+ // Delete the archive from an existing install to save some disk
space. We
+ // make this an unconditional work item since there's no need to roll
this
+ // back; if installation fails we'll be moved to the "-full" channel
anyway.
+ FilePath old_installer_dir(
+ installer_state.GetInstallerDirectory(**current_version));
+ FilePath
old_archive(old_installer_dir.Append(archive_path.BaseName()));
+ install_list->AddDeleteTreeWorkItem(old_archive, temp_path)
+ ->set_ignore_failure(true);
+ }
+
// Delete any new_chrome.exe if present (we will end up creating a new
one
// if required) and then copy chrome.exe
- FilePath new_chrome_exe(
- target_path.Append(installer::kChromeNewExe));
+ FilePath new_chrome_exe(target_path.Append(installer::kChromeNewExe));

install_list->AddDeleteTreeWorkItem(new_chrome_exe, temp_path);
install_list->AddCopyTreeWorkItem(
Index: chrome/installer/util/delete_tree_work_item.cc
===================================================================
--- chrome/installer/util/delete_tree_work_item.cc (revision 77812)
+++ chrome/installer/util/delete_tree_work_item.cc (working copy)
@@ -104,19 +104,24 @@

// Now that we've taken care of the key files, take care of the rest.
if (!root_path_.empty() && file_util::PathExists(root_path_)) {
- if (!backup_path_.CreateUniqueTempDirUnderPath(temp_path_)) {
- PLOG(ERROR) << "Failed to get backup path in folder "
- << temp_path_.value();
- return ignore_failure_;
- } else {
- FilePath backup = backup_path_.path().Append(root_path_.BaseName());
- if (!file_util::CopyDirectory(root_path_, backup, true) ||
- !file_util::Delete(root_path_, true)) {
- LOG(ERROR) << "can not delete " << root_path_.value()
- << " OR copy it to backup path " << backup.value();
- return ignore_failure_;
+ if (!ignore_failure_) {
+ if (!backup_path_.CreateUniqueTempDirUnderPath(temp_path_)) {
+ PLOG(ERROR) << "Failed to get backup path in folder "
+ << temp_path_.value();
+ return false;
+ } else {
+ FilePath backup =
backup_path_.path().Append(root_path_.BaseName());
+ if (!file_util::CopyDirectory(root_path_, backup, true)) {
+ LOG(ERROR) << "can not copy " << root_path_.value()
+ << " to backup path " << backup.value();
+ return false;
+ }
}
}
+ if (!file_util::Delete(root_path_, true)) {
+ LOG(ERROR) << "can not delete " << root_path_.value();
+ return ignore_failure_;
+ }
}

return true;


to...@chromium.org

unread,
Mar 11, 2011, 4:11:44 PM3/11/11
to g...@chromium.org, robert...@chromium.org, chromium...@chromium.org

robert...@chromium.org

unread,
Mar 11, 2011, 4:28:17 PM3/11/11
to g...@chromium.org, to...@chromium.org, chromium...@chromium.org
Reply all
Reply to author
Forward
0 new messages