summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-05-11 11:20:30 +0200
committerSamuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>2022-05-11 14:18:44 +0200
commit86453991a7ca0c7f90ae95769ee23cd5ccecd83f (patch)
tree03a14ac3f8157de7e54ce674d8852563833c32d4
parent1e016920769ae524575e40b1ec317c700ba0daa3 (diff)
Add error handling to RenamePrgFolder and RemovePrgFolder
These routines can fail during MSI installation (seen leftover program_old folders, with program folder missing). We at least want to see the error in the MSI log file when this doesn't succeed. This outputs error messages like: MSI (s) (C4:5C) [10:47:54:280]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI37B4.tmp, Entrypoint: RemovePrgFolder CustomAction RemovePrgFolder returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 10:47:54: RemovePrgFolder. Return value 3. Change-Id: I4ce4099eeb3e0ee79eb4a2e1d3887f9810fd9669 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134160 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
-rw-r--r--setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx22
1 files changed, 18 insertions, 4 deletions
diff --git a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
index e61f4a43f38e..4009d7887ab1 100644
--- a/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
+++ b/setup_native/source/win32/customactions/shellextensions/vistaspecial.cxx
@@ -80,6 +80,12 @@ static bool RemoveCompleteDirectoryW(const std::wstring& rPath)
return bDirectoryRemoved;
}
+/** Move program folder to program_old. Tries 10 times (program_old1, program_old2, ...).
+ *
+ * @return
+ * ERROR_INSTALL_FAILURE when the folder cannot be moved.
+ * ERROR_SUCCESS otherwise.
+ */
extern "C" __declspec(dllexport) UINT __stdcall RenamePrgFolder( MSIHANDLE handle )
{
std::wstring sOfficeInstallPath = GetMsiPropertyW(handle, L"INSTALLLOCATION");
@@ -101,22 +107,30 @@ extern "C" __declspec(dllexport) UINT __stdcall RenamePrgFolder( MSIHANDLE handl
}
}
- // ? This succeeds unconditionally, even if bSuccess is false!
- return ERROR_SUCCESS;
+ return bSuccess ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE;
}
+
+/** Remove leftover program_old folder(s).
+ *
+ * @return
+ * ERROR_INSTALL_FAILURE when the folder cannot be removed.
+ * ERROR_SUCCESS otherwise.
+ */
extern "C" __declspec(dllexport) UINT __stdcall RemovePrgFolder( MSIHANDLE handle )
{
std::wstring sOfficeInstallPath = GetMsiPropertyW(handle, L"INSTALLLOCATION");
std::wstring sRemoveDir = sOfficeInstallPath + L"program_old";
- RemoveCompleteDirectoryW( sRemoveDir );
+ if (!RemoveCompleteDirectoryW(sRemoveDir))
+ return ERROR_INSTALL_FAILURE;
WCHAR sAppend[2] = L"0";
for ( int i = 0; i < 10; i++ )
{
sRemoveDir = sOfficeInstallPath + L"program_old" + sAppend;
- RemoveCompleteDirectoryW( sRemoveDir );
+ if (!RemoveCompleteDirectoryW( sRemoveDir ))
+ return ERROR_INSTALL_FAILURE;
sAppend[0] += 1;
}