Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5518)

Unified Diff: chrome/installer/util/installer_state.cc

Issue 8299008: Errors while deleting old version dirs no longer cause them to grow in odd ways. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addresses nits Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/util/delete_tree_work_item.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/util/installer_state.cc
diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc
index ba0740d7f9189156044f4f1c7cae1f35ed728e8a..bc365de421198549c97fb728c00bc7fdd9ce6f30 100644
--- a/chrome/installer/util/installer_state.cc
+++ b/chrome/installer/util/installer_state.cc
@@ -448,50 +448,42 @@ void InstallerState::RemoveOldVersionDirectories(
const Version& new_version,
Version* existing_version,
const FilePath& temp_path) const {
- file_util::FileEnumerator version_enum(target_path(), false,
- file_util::FileEnumerator::DIRECTORIES);
scoped_ptr<Version> version;
std::vector<FilePath> key_files;
+ scoped_ptr<WorkItem> item;
- // We try to delete all directories whose versions are lower than
- // latest_version.
- FilePath next_version = version_enum.Next();
- while (!next_version.empty()) {
- file_util::FileEnumerator::FindInfo find_data = {0};
- version_enum.GetFindInfo(&find_data);
- VLOG(1) << "directory found: " << find_data.cFileName;
- version.reset(Version::GetVersionFromString(
- WideToASCII(find_data.cFileName)));
- if (version.get()) {
- // Delete the version folder if it is less than the new version and not
- // equal to the old version (if we have an old version).
- if (version->CompareTo(new_version) < 0 &&
- (existing_version == NULL ||
- version->CompareTo(*existing_version) != 0)) {
- key_files.clear();
- std::for_each(products_.begin(), products_.end(),
- std::bind2nd(std::mem_fun(&Product::AddKeyFiles),
- &key_files));
- const std::vector<FilePath>::iterator end = key_files.end();
- for (std::vector<FilePath>::iterator scan = key_files.begin();
- scan != end; ++scan) {
- *scan = next_version.Append(*scan);
- }
+ // Try to delete all directories whose versions are lower than latest_version
+ // and not equal to the existing version (opv).
+ file_util::FileEnumerator version_enum(target_path(), false,
+ file_util::FileEnumerator::DIRECTORIES);
+ for (FilePath next_version = version_enum.Next(); !next_version.empty();
+ next_version = version_enum.Next()) {
+ FilePath dir_name(next_version.BaseName());
+ version.reset(Version::GetVersionFromString(WideToASCII(dir_name.value())));
+ // Delete the version folder if it is less than the new version and not
+ // equal to the old version (if we have an old version).
+ if (version.get() &&
+ version->CompareTo(new_version) < 0 &&
+ (existing_version == NULL || !version->Equals(*existing_version))) {
+ // Collect the key files (relative to the version dir) for all products.
+ key_files.clear();
+ std::for_each(products_.begin(), products_.end(),
+ std::bind2nd(std::mem_fun(&Product::AddKeyFiles),
+ &key_files));
+ // Make the key_paths absolute.
+ const std::vector<FilePath>::iterator end = key_files.end();
+ for (std::vector<FilePath>::iterator scan = key_files.begin();
+ scan != end; ++scan) {
+ *scan = next_version.Append(*scan);
+ }
- VLOG(1) << "Deleting directory: " << next_version.value();
+ VLOG(1) << "Deleting old version directory: " << next_version.value();
- scoped_ptr<WorkItem> item(
- WorkItem::CreateDeleteTreeWorkItem(next_version, temp_path,
- key_files));
- if (!item->Do()) {
- LOG(ERROR) << "Failed to delete old version directory: "
- << next_version.value();
- item->Rollback();
- }
- }
+ item.reset(WorkItem::CreateDeleteTreeWorkItem(next_version, temp_path,
+ key_files));
+ item->set_ignore_failure(true);
+ item->Do();
}
-
- next_version = version_enum.Next();
}
}
« no previous file with comments | « chrome/installer/util/delete_tree_work_item.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698