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

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 failure 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 25 matching lines...) Expand all
36 // If dest_path_ exists, we can do one of two things: 36 // If dest_path_ exists, we can do one of two things:
37 // 1) If the contents of src_path_are already fully contained in dest_path_ 37 // 1) If the contents of src_path_are already fully contained in dest_path_
38 // then do nothing and return success. Fully contained means the full 38 // then do nothing and return success. Fully contained means the full
39 // file structure with identical files is contained in dest_path_. For 39 // file structure with identical files is contained in dest_path_. For
40 // Chrome, if dest_path_ exists, this is expected to be the common case. 40 // Chrome, if dest_path_ exists, this is expected to be the common case.
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_dir_.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 backup_path_ = backup_dir_.GetPath();
gab 2016/09/28 16:31:59 Just like copy_tree_work_item.cc, looks like the o
vabr (Chromium) 2016/09/28 20:06:36 Looking at the test failures in the first patch se
gab 2016/09/28 20:25:25 Right, I think obtaining the variable should be in
vabr (Chromium) 2016/09/28 20:33:11 Good idea, I will do that.
52
53 base::FilePath backup = backup_path_.Append(dest_path_.BaseName());
52 54
53 if (duplicate_option_ == CHECK_DUPLICATES) { 55 if (duplicate_option_ == CHECK_DUPLICATES) {
54 if (installer::IsIdenticalFileHierarchy(source_path_, dest_path_)) { 56 if (installer::IsIdenticalFileHierarchy(source_path_, dest_path_)) {
55 // The files we are moving are already present in the destination path. 57 // 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 58 // We most likely don't need to do anything. As such, just move the
57 // source files to the temp folder as backup. 59 // source files to the temp folder as backup.
58 if (base::Move(source_path_, backup)) { 60 if (base::Move(source_path_, backup)) {
59 source_moved_to_backup_ = true; 61 source_moved_to_backup_ = true;
60 VLOG(1) << "Moved source " << source_path_.value() 62 VLOG(1) << "Moved source " << source_path_.value()
61 << " to backup path " << backup.value(); 63 << " to backup path " << backup.value();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 100
99 return true; 101 return true;
100 } 102 }
101 103
102 void MoveTreeWorkItem::RollbackImpl() { 104 void MoveTreeWorkItem::RollbackImpl() {
103 if (moved_to_dest_path_ && !base::Move(dest_path_, source_path_)) { 105 if (moved_to_dest_path_ && !base::Move(dest_path_, source_path_)) {
104 PLOG(ERROR) << "Can not move " << dest_path_.value() 106 PLOG(ERROR) << "Can not move " << dest_path_.value()
105 << " to " << source_path_.value(); 107 << " to " << source_path_.value();
106 } 108 }
107 109
108 base::FilePath backup = backup_path_.path().Append(dest_path_.BaseName()); 110 base::FilePath backup = backup_path_.Append(dest_path_.BaseName());
109 if (moved_to_backup_ && !base::Move(backup, dest_path_)) { 111 if (moved_to_backup_ && !base::Move(backup, dest_path_)) {
110 PLOG(ERROR) << "failed move " << backup.value() 112 PLOG(ERROR) << "failed move " << backup.value()
111 << " to " << dest_path_.value(); 113 << " to " << dest_path_.value();
112 } 114 }
113 115
114 if (source_moved_to_backup_ && !base::Move(backup, source_path_)) { 116 if (source_moved_to_backup_ && !base::Move(backup, source_path_)) {
115 PLOG(ERROR) << "Can not restore " << backup.value() 117 PLOG(ERROR) << "Can not restore " << backup.value()
116 << " to " << source_path_.value(); 118 << " to " << source_path_.value();
117 } 119 }
118 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698