Skip to content

Commit

Permalink
Fix file iterator- graceful recovery if base folder doesn't exist or …
Browse files Browse the repository at this point in the history
…is empty
  • Loading branch information
nirbar committed Nov 26, 2024
1 parent fcc1358 commit 55df6d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/PanelSwCustomActions/FileIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ CFileEntry CFileIterator::Find(LPCWSTR szBasePath, LPCWSTR szPattern, bool bRecu

// We're searching without filespec wildcard pattern so we can match subfolders
_hFind = ::FindFirstFile(szBasePattern, &_findData);
ExitOnInvalidHandleWithLastError(_hFind, _hrStatus, "Failed to find files in '%ls'", szBasePath);
if (_hFind == INVALID_HANDLE_VALUE)
{
DWORD dwError = ::GetLastError();
if ((dwError == ERROR_FILE_NOT_FOUND) || (dwError == ERROR_PATH_NOT_FOUND) || (dwError == ERROR_NO_MORE_FILES))
{
_hrStatus = E_NOMOREFILES;
ExitFunction();
}
ExitOnWin32Error(dwError, _hrStatus, "Failed to find files in '%ls'", szBasePath);
}

return ProcessFindData();

Expand Down
2 changes: 1 addition & 1 deletion src/TidyBuild.custom.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)TidyBuild.user.props" Condition="Exists('$(MSBuildThisFileDirectory)TidyBuild.user.props')"/>
<PropertyGroup>
<FullVersion>3.22.0</FullVersion>
<FullVersion>3.22.1</FullVersion>
<FullVersion Condition=" '$(GITHUB_RUN_NUMBER)'!='' ">$(FullVersion).$(GITHUB_RUN_NUMBER)</FullVersion>
<ProductName>PanelSwWixExtension</ProductName>
<Manufacturer>Panel::Software</Manufacturer>
Expand Down
4 changes: 3 additions & 1 deletion src/UnitTests/FileOperationsUT/FileOperationsUT.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<PanelSW:DeletePath Path="[DeleteMeDir]FileOperationsUT.wxs" Condition="Not Installed"/>
<PanelSW:DeletePath Path="[EmptyDir]" OnlyIfEmpty="yes" AllowReboot="no" Condition="Not Installed"/>

<Property Id="MSIFASTINSTALL" Value="1"></Property>
<Property Id="MSIFASTINSTALL" Value="1"/>
<SetProperty Id="NONEXISTENT_FOLDER" Value="[OriginalDatabase].doesnt_exist" Before="AppSearch" Sequence="both"/>

<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="Test">
Expand All @@ -27,6 +28,7 @@
<PanelSW:RemoveFolderEx Property="REMOVE_ON_INSTALL" On="install"/>
<PanelSW:RemoveFolderEx Property="REMOVE_ON_UNINSTALL" On="uninstall"/>
<PanelSW:RemoveFolderEx Property="REMOVE_ON_BOTH" On="both"/>
<PanelSW:RemoveFolderEx Property="NONEXISTENT_FOLDER" On="both"/>

<RemoveFile Property="REMOVE_NO_RECURSIVE" Name="file.txt" On="both"/>
<RemoveFolder Property="REMOVE_NO_RECURSIVE" On="both"/>
Expand Down

0 comments on commit 55df6d2

Please sign in to comment.