• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Révision29260 (tree)
l'heure2021-09-18 02:12:42
Auteurstefankueng

Message de Log

use FindPackagesForUser instead of FindPackages to work around admin issues, and show errors properly

Change Summary

Modification

--- trunk/src/TortoiseSVNSetup/CustomActions/CustomActions11.cpp (revision 29259)
+++ trunk/src/TortoiseSVNSetup/CustomActions/CustomActions11.cpp (revision 29260)
@@ -85,23 +85,48 @@
8585 len += 1;
8686 MsiGetPropertyW(hModule, L"SPARSEPACKAGENAME", sparsePackageName.get(), &len);
8787
88- PackageManager packageManager;
88+ PackageManager packageManager;
89+ Collections::IIterable<winrt::Windows::ApplicationModel::Package> packages;
90+ try
91+ {
92+ packages = packageManager.FindPackagesForUser(L"");
93+ }
94+ catch (winrt::hresult_error const& ex)
95+ {
96+ PMSIHANDLE hRecord = MsiCreateRecord(0);
97+ std::wstring error = L"FindPackagesForUser failed (Errorcode: ";
98+ error += std::to_wstring(ex.code().value);
99+ error += L"):\n";
100+ error += ex.message();
101+ MsiRecordSetStringW(hRecord, 0, error.c_str());
102+ MsiProcessMessage(hModule, INSTALLMESSAGE_ERROR, hRecord);
103+ MsiCloseHandle(hRecord);
89104
90- auto packages = packageManager.FindPackages();
91- winrt::hstring fullName = sparsePackageName.get();
105+ return ERROR_INSTALL_FAILURE;
106+ }
107+
92108 for (const auto& package : packages)
93109 {
94- if (package.Id().Name() == sparsePackageName.get())
95- {
96- fullName = package.Id().FullName();
97- auto deploymentOperation = packageManager.RemovePackageAsync(fullName, RemovalOptions::None);
98- auto deployResult = deploymentOperation.get();
99- if (!SUCCEEDED(deployResult.ExtendedErrorCode()))
100- {
101- // Deployment failed
102- return deployResult.ExtendedErrorCode();
103- }
104- }
110+ if (package.Id().Name() != sparsePackageName.get())
111+ continue;
112+
113+ winrt::hstring fullName = package.Id().FullName();
114+ auto deploymentOperation = packageManager.RemovePackageAsync(fullName, RemovalOptions::None);
115+ auto deployResult = deploymentOperation.get();
116+ if (SUCCEEDED(deployResult.ExtendedErrorCode()))
117+ break;
118+
119+ // Undeployment failed
120+ PMSIHANDLE hRecord = MsiCreateRecord(0);
121+ std::wstring error = L"RemovePackageAsync failed (Errorcode: ";
122+ error += std::to_wstring(deployResult.ExtendedErrorCode());
123+ error += L"):\n";
124+ error += deployResult.ErrorText();
125+ MsiRecordSetStringW(hRecord, 0, error.c_str());
126+ MsiProcessMessage(hModule, INSTALLMESSAGE_ERROR, hRecord);
127+ MsiCloseHandle(hRecord);
128+
129+ return ERROR_INSTALL_FAILURE;
105130 }
106131
107132 return ERROR_SUCCESS;
Afficher sur ancien navigateur de dépôt.