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

Side by Side Diff: chrome/installer/setup/install.cc

Issue 43064: Revert the change in installer.cc to use MoveFile instead of CopyFile.... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/169/src/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <time.h> 5 #include <time.h>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/registry.h" 8 #include "base/registry.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 std::wstring exe_dst(installer_dir); 102 std::wstring exe_dst(installer_dir);
103 std::wstring archive_dst(installer_dir); 103 std::wstring archive_dst(installer_dir);
104 file_util::AppendToPath(&exe_dst, 104 file_util::AppendToPath(&exe_dst,
105 file_util::GetFilenameFromPath(exe_path)); 105 file_util::GetFilenameFromPath(exe_path));
106 file_util::AppendToPath(&archive_dst, 106 file_util::AppendToPath(&archive_dst,
107 file_util::GetFilenameFromPath(archive_path)); 107 file_util::GetFilenameFromPath(archive_path));
108 108
109 install_list->AddCopyTreeWorkItem(exe_path, exe_dst, temp_path, 109 install_list->AddCopyTreeWorkItem(exe_path, exe_dst, temp_path,
110 WorkItem::ALWAYS); 110 WorkItem::ALWAYS);
111 install_list->AddMoveTreeWorkItem(archive_path, archive_dst, temp_path); 111 install_list->AddCopyTreeWorkItem(archive_path, archive_dst, temp_path,
112 WorkItem::ALWAYS);
112 } 113 }
113 114
114 115
115 // This method tells if we are running on 64 bit platform so that we can copy 116 // This method tells if we are running on 64 bit platform so that we can copy
116 // one extra exe. If the API call to determine 64 bit fails, we play it safe 117 // one extra exe. If the API call to determine 64 bit fails, we play it safe
117 // and return true anyway so that the executable can be copied. 118 // and return true anyway so that the executable can be copied.
118 bool Is64bit() { 119 bool Is64bit() {
119 typedef BOOL (WINAPI *WOW_FUNC)(HANDLE, PBOOL); 120 typedef BOOL (WINAPI *WOW_FUNC)(HANDLE, PBOOL);
120 BOOL is64 = FALSE; 121 BOOL is64 = FALSE;
121 122
(...skipping 19 matching lines...) Expand all
141 const Version& new_version) { 142 const Version& new_version) {
142 143
143 if (reg_root != HKEY_LOCAL_MACHINE && reg_root != HKEY_CURRENT_USER) 144 if (reg_root != HKEY_LOCAL_MACHINE && reg_root != HKEY_CURRENT_USER)
144 return false; 145 return false;
145 146
146 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); 147 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList());
147 // A temp directory that work items need and the actual install directory. 148 // A temp directory that work items need and the actual install directory.
148 install_list->AddCreateDirWorkItem(temp_dir); 149 install_list->AddCreateDirWorkItem(temp_dir);
149 install_list->AddCreateDirWorkItem(install_path); 150 install_list->AddCreateDirWorkItem(install_path);
150 151
151 // Move the version folder 152 // Copy the version folder
152 install_list->AddMoveTreeWorkItem( 153 install_list->AddCopyTreeWorkItem(
153 AppendPath(src_path, new_version.GetString()), 154 AppendPath(src_path, new_version.GetString()),
154 AppendPath(install_path, new_version.GetString()), 155 AppendPath(install_path, new_version.GetString()),
155 temp_dir); 156 temp_dir, WorkItem::ALWAYS); // Always overwrite.
156 157
157 // Delete any new_chrome.exe if present (we will end up create a new one 158 // Delete any new_chrome.exe if present (we will end up create a new one
158 // if required) and then copy chrome.exe 159 // if required) and then copy chrome.exe
159 std::wstring new_chrome_exe = AppendPath(install_path, 160 std::wstring new_chrome_exe = AppendPath(install_path,
160 installer_util::kChromeNewExe); 161 installer_util::kChromeNewExe);
161 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 162 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
162 RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ); 163 RegKey chrome_key(reg_root, dist->GetVersionKey().c_str(), KEY_READ);
163 std::wstring current_version; 164 std::wstring current_version;
164 if (file_util::PathExists(new_chrome_exe)) 165 if (file_util::PathExists(new_chrome_exe))
165 chrome_key.ReadValue(google_update::kRegOldVersionField, &current_version); 166 chrome_key.ReadValue(google_update::kRegOldVersionField, &current_version);
166 if (current_version.empty()) 167 if (current_version.empty())
167 chrome_key.ReadValue(google_update::kRegVersionField, &current_version); 168 chrome_key.ReadValue(google_update::kRegVersionField, &current_version);
168 chrome_key.Close(); 169 chrome_key.Close();
169 170
170 install_list->AddDeleteTreeWorkItem(new_chrome_exe, std::wstring()); 171 install_list->AddDeleteTreeWorkItem(new_chrome_exe, std::wstring());
171 install_list->AddCopyTreeWorkItem( 172 install_list->AddCopyTreeWorkItem(
172 AppendPath(src_path, installer_util::kChromeExe), 173 AppendPath(src_path, installer_util::kChromeExe),
173 AppendPath(install_path, installer_util::kChromeExe), 174 AppendPath(install_path, installer_util::kChromeExe),
174 temp_dir, WorkItem::NEW_NAME_IF_IN_USE, new_chrome_exe); 175 temp_dir, WorkItem::NEW_NAME_IF_IN_USE, new_chrome_exe);
175 176
176 // Extra executable for 64 bit systems. 177 // Extra executable for 64 bit systems.
177 if (Is64bit()) { 178 if (Is64bit()) {
178 install_list->AddMoveTreeWorkItem( 179 install_list->AddCopyTreeWorkItem(
179 AppendPath(src_path, installer::kWowHelperExe), 180 AppendPath(src_path, installer::kWowHelperExe),
180 AppendPath(install_path, installer::kWowHelperExe), 181 AppendPath(install_path, installer::kWowHelperExe),
181 temp_dir); 182 temp_dir, WorkItem::ALWAYS);
182 } 183 }
183 184
184 // Copy the default Dictionaries only if the folder doesnt exist already 185 // Copy the default Dictionaries only if the folder doesnt exist already
185 install_list->AddCopyTreeWorkItem( 186 install_list->AddCopyTreeWorkItem(
186 AppendPath(src_path, installer::kDictionaries), 187 AppendPath(src_path, installer::kDictionaries),
187 AppendPath(install_path, installer::kDictionaries), 188 AppendPath(install_path, installer::kDictionaries),
188 temp_dir, WorkItem::IF_NOT_PRESENT); 189 temp_dir, WorkItem::IF_NOT_PRESENT);
189 190
190 // Copy installer in install directory and 191 // Copy installer in install directory and
191 // add shortcut in Control Panel->Add/Remove Programs. 192 // add shortcut in Control Panel->Add/Remove Programs.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 270 }
270 271
271 if (!success) { 272 if (!success) {
272 LOG(ERROR) << "Install failed, rolling back... "; 273 LOG(ERROR) << "Install failed, rolling back... ";
273 install_list->Rollback(); 274 install_list->Rollback();
274 LOG(ERROR) << "Rollback complete. "; 275 LOG(ERROR) << "Rollback complete. ";
275 } 276 }
276 return success; 277 return success;
277 } 278 }
278 279
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698