Skip to content

Commit

Permalink
Fix zipping large folders- resultant zip file was invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
nirbar committed Dec 8, 2024
1 parent c780196 commit 1de94ec
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/github-actions-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
cmake.exe --build build-v142\protobuf --config Release
cmake.exe -G "Visual Studio 16 2019" -T v141_xp,host=x86 -A Win32 .\protobuf\cmake -Dprotobuf_BUILD_TESTS=OFF -B build\protobuf
cmake.exe --build build\protobuf --config Release
cmake.exe -G "Visual Studio 16 2019" -T v141_xp,host=x86 -A Win32 .\poco -DPOCO_STATIC=ON -DPOCO_MT=ON -B build\poco
cmake.exe -G "Visual Studio 16 2019" -T v141_xp,host=x86 -A Win32 .\poco -DPOCO_MT=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DENABLE_XML=ON -DENABLE_ZIP=ON -DENABLE_ENCODINGS=OFF -DENABLE_UTIL=OFF -DENABLE_NET=OFF -DENABLE_MONGODB=OFF -DENABLE_REDIS=OFF -DENABLE_DNSSD=OFF -DENABLE_PROMETHEUS=OFF -DENABLE_PDF=OFF -DENABLE_JWT=OFF -DENABLE_NETSSL_WIN=OFF -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_DATA=OFF -DENABLE_DATA_SQLITE=OFF -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_ACTIVERECORD=OFF -DENABLE_ACTIVERECORD_COMPILER=OFF -DENABLE_APACHECONNECTOR=OFF -DENABLE_CPPPARSER=OFF -DENABLE_POCODOC=OFF -DENABLE_PAGECOMPILER=OFF -DENABLE_PAGECOMPILER_FILE2PAGE=OFF -DENABLE_ENCODINGS_COMPILER=OFF -DENABLE_TRACE=OFF -DENABLE_TESTS=OFF -DENABLE_DATA_ODBC=OFF -B build\poco
cmake.exe --build build\poco --config Release
- name: Build CaCommon v142
Expand Down
2 changes: 2 additions & 0 deletions PanelSwCustomActions/ExecOnComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "ExecOnComponent.h"
#include "../CaCommon/RegistryKey.h"
#include <Poco/JSON/Parser.h>
#include <Poco/JSON/Object.h>
#include <Poco/JSON/JSONException.h>
#include "FileOperations.h"
#include "../CaCommon/WixString.h"
#include <regex>
Expand Down
11 changes: 6 additions & 5 deletions PanelSwCustomActions/PanelSwCustomActions.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</ClCompile>
<Link>
<AdditionalDependencies>CaCommon.lib;libprotobuf-lite.lib;ProtoCaLib.lib;msi.lib;dutil.lib;wcautil.lib;Version.lib;Shell32.lib;User32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(WixSdkPath)\$(WixPlatformToolset)\lib\x86;$(OutDir)\..\CaCommon\;$(OutDir)\..\ProtoCaLib;$(BuildFolder)\poco\lib\$(Configuration);$(BuildFolder)\protobuf\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(WixSdkPath)\$(WixPlatformToolset)\lib\x86;$(OutDir)\..\CaCommon\;$(OutDir)\..\ProtoCaLib;$(BuildFolder)\poco\lib\;$(BuildFolder)\protobuf\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
Expand All @@ -62,6 +62,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down Expand Up @@ -213,11 +214,11 @@
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixNativeCATargetsImported)' != 'true' ">
<Error Text="The WiX Toolset v3.11 (or newer) build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
</Target>
<Target Name="BuildPoco" BeforeTargets="PrepareForBuild" Condition="!Exists('$(BuildFolder)\poco\lib\$(Configuration)\PocoZipmt.lib')">
<Target Name="BuildPoco" BeforeTargets="PrepareForBuild" Condition="!Exists('$(BuildFolder)\poco\lib\PocoZipmt.lib')">
<MakeDir Directories="$(BuildFolder)\poco;$(IntDir)\..\poco" />
<MakeDir Directories="" />
<Exec Command="&quot;$(CMakeDir)\cmake.exe&quot; -G &quot;$(CMakeVsVersion)&quot; -T $(PlatformToolset),host=x86 -A Win32 -DPOCO_STATIC=ON -DPOCO_MT=ON ..\..\poco" WorkingDirectory="$(BuildFolder)\poco" />
<Exec Command="&quot;$(CMakeDir)\cmake.exe&quot; --build . --config $(Configuration)" WorkingDirectory="$(BuildFolder)\poco" />
<Exec Command="&quot;$(CMakeDir)cmake.exe&quot; -G &quot;$(CMakeVsVersion)&quot; -T $(PlatformToolset),host=x86 -A Win32 -DPOCO_MT=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DENABLE_XML=ON -DENABLE_ZIP=ON -DENABLE_ENCODINGS=OFF -DENABLE_UTIL=OFF -DENABLE_NET=OFF -DENABLE_MONGODB=OFF -DENABLE_REDIS=OFF -DENABLE_DNSSD=OFF -DENABLE_PROMETHEUS=OFF -DENABLE_PDF=OFF -DENABLE_JWT=OFF -DENABLE_NETSSL_WIN=OFF -DENABLE_NETSSL=OFF -DENABLE_CRYPTO=OFF -DENABLE_DATA=OFF -DENABLE_DATA_SQLITE=OFF -DENABLE_DATA_MYSQL=OFF -DENABLE_DATA_POSTGRESQL=OFF -DENABLE_ACTIVERECORD=OFF -DENABLE_ACTIVERECORD_COMPILER=OFF -DENABLE_APACHECONNECTOR=OFF -DENABLE_CPPPARSER=OFF -DENABLE_POCODOC=OFF -DENABLE_PAGECOMPILER=OFF -DENABLE_PAGECOMPILER_FILE2PAGE=OFF -DENABLE_ENCODINGS_COMPILER=OFF -DENABLE_TRACE=OFF -DENABLE_TESTS=OFF -DENABLE_DATA_ODBC=OFF ..\..\poco" WorkingDirectory="$(BuildFolder)\poco" />
<Exec Command="&quot;$(CMakeDir)cmake.exe&quot; --build . --config $(Configuration)" WorkingDirectory="$(BuildFolder)\poco" />
</Target>
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\MSBuildTasks.1.5.0.235\build\MSBuildTasks.targets" Condition="Exists('..\packages\MSBuildTasks.1.5.0.235\build\MSBuildTasks.targets')" />
Expand All @@ -231,4 +232,4 @@
<Error Condition="!Exists('..\packages\TidyBuild.1.5.2\build\TidyBuild.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\TidyBuild.1.5.2\build\TidyBuild.props'))" />
<Error Condition="!Exists('..\packages\TidyBuild.1.5.2\build\TidyBuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\TidyBuild.1.5.2\build\TidyBuild.targets'))" />
</Target>
</Project>
</Project>
3 changes: 3 additions & 0 deletions PanelSwCustomActions/PanelSwCustomActions.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@
<ClInclude Include="FileIterator.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="$(BuildFolder)\obj\$(Configuration)\Protobuf\reparsePointDetails.pb.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
13 changes: 9 additions & 4 deletions PanelSwCustomActions/Unzip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ HRESULT CUnzip::ExecuteOneZip(::com::panelsw::ca::ZipDetails* pDetails)
zipFileStream = new std::ofstream(zipFileA, std::ios::binary);
ExitOnNull(zipFileStream, hr, E_OUTOFMEMORY, "Failed creating zip file '%ls'", zipFileW);

pZip = new Compress(*zipFileStream, true);
pZip = new Compress(*zipFileStream, true, true);
ExitOnNull(zipFileStream, hr, E_OUTOFMEMORY, "Failed creating zip archive for '%ls'", zipFileW);

for (CFileEntry fileEntry = fileFinder.Find(srcFolderW, szPattern, pDetails->recursive()); !fileFinder.IsEnd(); fileEntry = fileFinder.Next())
Expand Down Expand Up @@ -390,10 +390,15 @@ HRESULT CUnzip::ExecuteOneZip(::com::panelsw::ca::ZipDetails* pDetails)
}
ExitOnFailure(hr, "Failed to add '%ls' to zip '%ls'", (LPCWSTR)fileEntry.Path(), zipFileW);
}

pZip->close();
zipFileStream->flush();
}

pZip->close();
delete pZip;
pZip = nullptr;

zipFileStream->flush();
delete zipFileStream;
zipFileStream = nullptr;
}
catch (Poco::Exception ex)
{
Expand Down
4 changes: 2 additions & 2 deletions TidyBuild.custom.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<Import Project="$(MSBuildThisFileDirectory)TidyBuild.user.props" Condition="Exists('$(MSBuildThisFileDirectory)TidyBuild.user.props')"/>
<PropertyGroup>
<FullVersion>3.13.2</FullVersion>
<FullVersion>3.13.3</FullVersion>
<FullVersion Condition=" '$(GITHUB_RUN_NUMBER)'!='' ">$(FullVersion).$(GITHUB_RUN_NUMBER)</FullVersion>
<ProductName>PanelSwWixExtension</ProductName>
<Manufacturer>Panel::Software</Manufacturer>
Expand All @@ -12,7 +12,7 @@
-->

<!-- CMake -->
<CMakeDir Condition="'$(CMakeDir)'==''">D:\Tools\cmake-3.26.4-windows-x86_64\bin\</CMakeDir>
<CMakeDir Condition="'$(CMakeDir)'==''">D:\Tools\cmake-3.30.3-windows-x86_64\bin\</CMakeDir>
<CMakeVsVersion Condition="'$(CMakeVsVersion)'==''">Visual Studio 16 2019</CMakeVsVersion>
<PlatformToolset Condition="'$(PlatformToolset)'==''">v141_xp</PlatformToolset>
<XPDeprecationWarning>false</XPDeprecationWarning>
Expand Down
2 changes: 1 addition & 1 deletion poco
Submodule poco updated 4212 files

0 comments on commit 1de94ec

Please sign in to comment.