| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/installer/util/delete_tree_work_item.h" | 5 #include "chrome/installer/util/delete_tree_work_item.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 base::ScopedTempDir& backup = key_backup_paths_[i]; | 60 base::ScopedTempDir& backup = key_backup_paths_[i]; |
| 61 if (!ignore_failure_) { | 61 if (!ignore_failure_) { |
| 62 if (!backup.CreateUniqueTempDirUnderPath(temp_path_)) { | 62 if (!backup.CreateUniqueTempDirUnderPath(temp_path_)) { |
| 63 PLOG(ERROR) << "Could not create temp dir in " << temp_path_.value(); | 63 PLOG(ERROR) << "Could not create temp dir in " << temp_path_.value(); |
| 64 abort = true; | 64 abort = true; |
| 65 } else if (!base::CopyFile(key_file, | 65 } else if (!base::CopyFile(key_file, |
| 66 backup.path().Append(key_file.BaseName()))) { | 66 backup.path().Append(key_file.BaseName()))) { |
| 67 PLOG(ERROR) << "Could not back up " << key_file.value() | 67 PLOG(ERROR) << "Could not back up " << key_file.value() |
| 68 << " to directory " << backup.path().value(); | 68 << " to directory " << backup.path().value(); |
| 69 abort = true; | 69 abort = true; |
| 70 backup.Delete(); | 70 if (!backup.Delete()) { |
| 71 PLOG(ERROR) << "Could not clean up temp dir in " |
| 72 << temp_path_.value(); |
| 73 } |
| 71 } | 74 } |
| 72 } | 75 } |
| 73 if (!abort) { | 76 if (!abort) { |
| 74 HANDLE file = ::CreateFile(key_file.value().c_str(), FILE_ALL_ACCESS, | 77 HANDLE file = ::CreateFile(key_file.value().c_str(), FILE_ALL_ACCESS, |
| 75 FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, | 78 FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, |
| 76 NULL); | 79 NULL); |
| 77 if (file != INVALID_HANDLE_VALUE) { | 80 if (file != INVALID_HANDLE_VALUE) { |
| 78 VLOG(1) << "Acquired exclusive lock for key file: " << key_file.value(); | 81 VLOG(1) << "Acquired exclusive lock for key file: " << key_file.value(); |
| 79 opened_key_files.push_back(file); | 82 opened_key_files.push_back(file); |
| 80 } else { | 83 } else { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 backup_dir.path().Append(key_file.BaseName()); | 158 backup_dir.path().Append(key_file.BaseName()); |
| 156 if (base::PathExists(backup_file) && | 159 if (base::PathExists(backup_file) && |
| 157 !base::Move(backup_file, key_file)) { | 160 !base::Move(backup_file, key_file)) { |
| 158 // This could happen if we could not delete the key file to begin with. | 161 // This could happen if we could not delete the key file to begin with. |
| 159 PLOG(WARNING) << "Rollback: Failed to move backup file back in place: " | 162 PLOG(WARNING) << "Rollback: Failed to move backup file back in place: " |
| 160 << backup_file.value() << " to " << key_file.value(); | 163 << backup_file.value() << " to " << key_file.value(); |
| 161 } | 164 } |
| 162 } | 165 } |
| 163 } | 166 } |
| 164 } | 167 } |
| OLD | NEW |