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(); | |
Lei Zhang
2015/10/07 16:28:09
Why not Delete() ?
dcheng
2015/10/07 16:41:34
It's a ScopedTmpDir, so it self-deletes anyway whe
Lei Zhang
2015/10/07 20:33:11
But |backup| is a reference to |key_backup_paths_[
dcheng
2015/10/08 03:48:07
Done. Thanks for pointing this out.
| |
71 } | 70 } |
72 } | 71 } |
73 if (!abort) { | 72 if (!abort) { |
74 HANDLE file = ::CreateFile(key_file.value().c_str(), FILE_ALL_ACCESS, | 73 HANDLE file = ::CreateFile(key_file.value().c_str(), FILE_ALL_ACCESS, |
75 FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, | 74 FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, |
76 NULL); | 75 NULL); |
77 if (file != INVALID_HANDLE_VALUE) { | 76 if (file != INVALID_HANDLE_VALUE) { |
78 VLOG(1) << "Acquired exclusive lock for key file: " << key_file.value(); | 77 VLOG(1) << "Acquired exclusive lock for key file: " << key_file.value(); |
79 opened_key_files.push_back(file); | 78 opened_key_files.push_back(file); |
80 } else { | 79 } else { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 backup_dir.path().Append(key_file.BaseName()); | 154 backup_dir.path().Append(key_file.BaseName()); |
156 if (base::PathExists(backup_file) && | 155 if (base::PathExists(backup_file) && |
157 !base::Move(backup_file, key_file)) { | 156 !base::Move(backup_file, key_file)) { |
158 // This could happen if we could not delete the key file to begin with. | 157 // 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: " | 158 PLOG(WARNING) << "Rollback: Failed to move backup file back in place: " |
160 << backup_file.value() << " to " << key_file.value(); | 159 << backup_file.value() << " to " << key_file.value(); |
161 } | 160 } |
162 } | 161 } |
163 } | 162 } |
164 } | 163 } |
OLD | NEW |