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

Side by Side Diff: chrome/installer/util/move_tree_work_item.cc

Issue 2379543002: installer and some misc files: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Fix compilation Created 4 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 unified diff | Download patch
OLDNEW
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/move_tree_work_item.h" 5 #include "chrome/installer/util/move_tree_work_item.h"
6 6
7 #include <shlwapi.h> 7 #include <shlwapi.h>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 30 matching lines...) Expand all
41 // 2) If the contents of src_path_ are NOT fully contained in dest_path_, we 41 // 2) If the contents of src_path_ are NOT fully contained in dest_path_, we
42 // attempt to backup dest_path_ and replace it with src_path_. This will 42 // attempt to backup dest_path_ and replace it with src_path_. This will
43 // fail if files in dest_path_ are in use. 43 // fail if files in dest_path_ are in use.
44 if (base::PathExists(dest_path_)) { 44 if (base::PathExists(dest_path_)) {
45 // Generate a backup path that can keep the original files under dest_path_. 45 // Generate a backup path that can keep the original files under dest_path_.
46 if (!backup_path_.CreateUniqueTempDirUnderPath(temp_dir_)) { 46 if (!backup_path_.CreateUniqueTempDirUnderPath(temp_dir_)) {
47 PLOG(ERROR) << "Failed to get backup path in folder " 47 PLOG(ERROR) << "Failed to get backup path in folder "
48 << temp_dir_.value(); 48 << temp_dir_.value();
49 return false; 49 return false;
50 } 50 }
51 base::FilePath backup = backup_path_.path().Append(dest_path_.BaseName()); 51 base::FilePath backup =
52 backup_path_.GetPath().Append(dest_path_.BaseName());
52 53
53 if (duplicate_option_ == CHECK_DUPLICATES) { 54 if (duplicate_option_ == CHECK_DUPLICATES) {
54 if (installer::IsIdenticalFileHierarchy(source_path_, dest_path_)) { 55 if (installer::IsIdenticalFileHierarchy(source_path_, dest_path_)) {
55 // The files we are moving are already present in the destination path. 56 // The files we are moving are already present in the destination path.
56 // We most likely don't need to do anything. As such, just move the 57 // We most likely don't need to do anything. As such, just move the
57 // source files to the temp folder as backup. 58 // source files to the temp folder as backup.
58 if (base::Move(source_path_, backup)) { 59 if (base::Move(source_path_, backup)) {
59 source_moved_to_backup_ = true; 60 source_moved_to_backup_ = true;
60 VLOG(1) << "Moved source " << source_path_.value() 61 VLOG(1) << "Moved source " << source_path_.value()
61 << " to backup path " << backup.value(); 62 << " to backup path " << backup.value();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 return true; 100 return true;
100 } 101 }
101 102
102 void MoveTreeWorkItem::RollbackImpl() { 103 void MoveTreeWorkItem::RollbackImpl() {
103 if (moved_to_dest_path_ && !base::Move(dest_path_, source_path_)) { 104 if (moved_to_dest_path_ && !base::Move(dest_path_, source_path_)) {
104 PLOG(ERROR) << "Can not move " << dest_path_.value() 105 PLOG(ERROR) << "Can not move " << dest_path_.value()
105 << " to " << source_path_.value(); 106 << " to " << source_path_.value();
106 } 107 }
107 108
108 base::FilePath backup = backup_path_.path().Append(dest_path_.BaseName()); 109 base::FilePath backup;
110 if (moved_to_backup_ || source_moved_to_backup_)
111 backup = backup_path_.GetPath().Append(dest_path_.BaseName());
gab 2016/09/29 13:36:00 The two ifs below only make sense within this cond
vabr (Chromium) 2016/09/30 07:40:10 Done.
109 if (moved_to_backup_ && !base::Move(backup, dest_path_)) { 112 if (moved_to_backup_ && !base::Move(backup, dest_path_)) {
110 PLOG(ERROR) << "failed move " << backup.value() 113 PLOG(ERROR) << "failed move " << backup.value()
111 << " to " << dest_path_.value(); 114 << " to " << dest_path_.value();
112 } 115 }
113 116
114 if (source_moved_to_backup_ && !base::Move(backup, source_path_)) { 117 if (source_moved_to_backup_ && !base::Move(backup, source_path_)) {
115 PLOG(ERROR) << "Can not restore " << backup.value() 118 PLOG(ERROR) << "Can not restore " << backup.value()
116 << " to " << source_path_.value(); 119 << " to " << source_path_.value();
117 } 120 }
118 } 121 }
OLDNEW
« no previous file with comments | « chrome/installer/util/delete_tree_work_item.cc ('k') | chrome/installer/util/shell_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698