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 f734c73 commit 15aa14d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/PanelSwBackendExtension/PanelSwBackendExtension.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ClCompile>
<Link>
<AdditionalDependencies>/WHOLEARCHIVE:7zrLib.lib;Version.lib;Shell32.lib;User32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SevenZapLibPath);$(BuildFolderCommon)$(Platform)\poco\lib\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SevenZapLibPath);$(BuildFolderCommon)$(Platform)\poco\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
<TargetMachine Condition="'$(Platform)' == 'x86'">MachineX86</TargetMachine>
<ModuleDefinitionFile>PanelSwBackendExtension.def</ModuleDefinitionFile>
Expand Down Expand Up @@ -85,9 +85,9 @@
<None Include="PanelSwBackendExtension.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Target Name="BuildPoco" BeforeTargets="PrepareForBuild" Condition="!Exists('$(BuildFolderCommon)$(Platform)\poco\lib\$(Configuration)\PocoZipmt.lib') Or !Exists('$(BuildFolderCommon)$(Platform)\poco\lib\$(Configuration)\PocoFoundationmt.lib')">
<Target Name="BuildPoco" BeforeTargets="PrepareForBuild" Condition="!Exists('$(BuildFolderCommon)$(Platform)\poco\lib\PocoZipmt.lib') Or !Exists('$(BuildFolderCommon)$(Platform)\poco\lib\PocoFoundationmt.lib')">
<MakeDir Directories="$(BuildFolderCommon)$(Platform)\poco" />
<Exec Command="&quot;$(CMakeDir)cmake.exe&quot; -G &quot;$(CMakeVsVersion)&quot; -A $(Platform) -T $(PlatformToolset),host=x86 -DPOCO_STATIC=ON -DPOCO_MT=ON &quot;$(MSBuildThisFileDirectory)..\poco&quot;" WorkingDirectory="$(BuildFolderCommon)$(Platform)\poco" />
<Exec Command="&quot;$(CMakeDir)cmake.exe&quot; -G &quot;$(CMakeVsVersion)&quot; -T $(PlatformToolset) -A $(Platform) -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 &quot;$(MSBuildThisFileDirectory)..\poco&quot;" WorkingDirectory="$(BuildFolderCommon)$(Platform)\poco" />
<Exec Command="&quot;$(CMakeDir)cmake.exe&quot; --build . --config $(Configuration)" WorkingDirectory="$(BuildFolderCommon)$(Platform)\poco" />
</Target>
</Project>
2 changes: 2 additions & 0 deletions src/PanelSwCustomActions/ExecOnComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,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 <regex>
#include <shlwapi.h>
Expand Down
7 changes: 4 additions & 3 deletions src/PanelSwCustomActions/PanelSwCustomActions.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</ClCompile>
<Link>
<AdditionalDependencies>CaCommon.lib;libprotobuf-lite.lib;ProtoCaLib.lib;msi.lib;Version.lib;Shell32.lib;User32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)\..\CaCommon\;$(OutDir)\..\ProtoCaLib;$(BuildFolderCommon)$(Platform)\poco\lib\$(Configuration);$(BuildFolderCommon)$(Platform)\protobuf\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(OutDir)\..\CaCommon\;$(OutDir)\..\ProtoCaLib;$(BuildFolderCommon)$(Platform)\poco\lib;$(BuildFolderCommon)$(Platform)\protobuf\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<SubSystem>Windows</SubSystem>
<TargetMachine Condition="'$(Platform)' == 'x86'">MachineX86</TargetMachine>
</Link>
Expand All @@ -57,6 +57,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand Down Expand Up @@ -204,9 +205,9 @@
</None>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Target Name="BuildPoco" BeforeTargets="PrepareForBuild" Condition="!Exists('$(BuildFolderCommon)$(Platform)\poco\lib\$(Configuration)\PocoZipmt.lib')">
<Target Name="BuildPoco" BeforeTargets="PrepareForBuild" Condition="!Exists('$(BuildFolderCommon)$(Platform)\poco\lib\PocoZipmt.lib')">
<MakeDir Directories="$(BuildFolderCommon)$(Platform)\poco" />
<Exec Command="&quot;$(CMakeDir)cmake.exe&quot; -G &quot;$(CMakeVsVersion)&quot; -T $(PlatformToolset),host=x86 -A $(Platform) -DPOCO_STATIC=ON -DPOCO_MT=ON &quot;$(MSBuildThisFileDirectory)..\poco&quot;" WorkingDirectory="$(BuildFolderCommon)$(Platform)\poco" />
<Exec Command="&quot;$(CMakeDir)cmake.exe&quot; -G &quot;$(CMakeVsVersion)&quot; -T $(PlatformToolset) -A $(Platform) -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 &quot;$(MSBuildThisFileDirectory)..\poco&quot;" WorkingDirectory="$(BuildFolderCommon)$(Platform)\poco" />
<Exec Command="&quot;$(CMakeDir)cmake.exe&quot; --build . --config $(Configuration)" WorkingDirectory="$(BuildFolderCommon)$(Platform)\poco" />
</Target>
</Project>
13 changes: 9 additions & 4 deletions src/PanelSwCustomActions/Unzip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,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 @@ -388,10 +388,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
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>5.4.4</FullVersion>
<FullVersion>5.4.5</FullVersion>
<FullVersion Condition=" '$(GITHUB_RUN_NUMBER)'!='' ">$(FullVersion).$(GITHUB_RUN_NUMBER)</FullVersion>
<ProductName>PanelSwWixExtension</ProductName>
<Manufacturer>Panel::Software</Manufacturer>
Expand Down
2 changes: 1 addition & 1 deletion src/poco
Submodule poco updated 4157 files

0 comments on commit 15aa14d

Please sign in to comment.