From d15272f2b1569510847574065e2dfe12e1e21ae4 Mon Sep 17 00:00:00 2001 From: dady8889 Date: Tue, 29 Mar 2022 14:49:59 +0200 Subject: [PATCH] fix: fixed empty files in zip, removed hidden console window --- Onova.Installer/Onova.Installer.cpp | 24 ++++++++++++++---------- Onova.Installer/unzip.cpp | 3 ++- Onova.Publisher.nuspec | 3 ++- Onova.Publisher/Onova.Publisher.csproj | 10 +++++++++- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/Onova.Installer/Onova.Installer.cpp b/Onova.Installer/Onova.Installer.cpp index e63d9b3..70a8025 100644 --- a/Onova.Installer/Onova.Installer.cpp +++ b/Onova.Installer/Onova.Installer.cpp @@ -13,10 +13,10 @@ int main(int argc, char* argv[]) cout << "WARNING: Your terminal does not support Unicode characters." << endl; } -#ifdef NDEBUG - // hide the console window - ShowWindow(GetConsoleWindow(), SW_HIDE); -#endif +//#ifdef NDEBUG +// // hide the console window +// ShowWindow(GetConsoleWindow(), SW_HIDE); +//#endif #ifndef NDEBUG wcout << "Attach debugger" << endl; @@ -70,10 +70,10 @@ int main(int argc, char* argv[]) } // show the window - ShowWindow(GetConsoleWindow(), SW_SHOW); + // ShowWindow(GetConsoleWindow(), SW_SHOW); wcout << L"Welcome to " << data.AppName << L" web install" << endl; - wcout << L"Downloading the latest version..." << endl; + wcout << L"Checking manifest..." << endl; // read the manifest ManifestMap manifestMap; @@ -100,7 +100,7 @@ int main(int argc, char* argv[]) return 1; } - wcout << L"Installing version " << ConvertAnsiToWide(newestEntry->first) << L"..." << endl; + wcout << L"Downloading version " << ConvertAnsiToWide(newestEntry->first) << L"..." << endl; wstring tempZipPath; @@ -114,6 +114,8 @@ int main(int argc, char* argv[]) wcout << L"Written zip to: " << tempZipPath << endl; #endif + wcout << L"Unpacking..." << endl; + // unpack the zip DWORD unpackedSize; wstring startupFilePath; @@ -226,10 +228,12 @@ bool LoadPublisherData(wstring selfFilePath, PublisherData_t* publisherData) // parse the structure char* pointer = buffer; - publisherData->AppName = std::wstring(reinterpret_cast(pointer), PUBLISHER_DATA_APPNAME_LEN / sizeof(wchar_t)); + size_t appNameSize = wcsnlen_s(reinterpret_cast(pointer), PUBLISHER_DATA_APPNAME_LEN / sizeof(wchar_t)); + publisherData->AppName = std::wstring(reinterpret_cast(pointer), appNameSize); pointer += PUBLISHER_DATA_APPNAME_LEN; - publisherData->ManifestUrl = std::string(pointer, PUBLISHER_DATA_MANIFESTURL_LEN); + size_t urlSize = strnlen_s(pointer, PUBLISHER_DATA_MANIFESTURL_LEN); + publisherData->ManifestUrl = std::string(pointer, urlSize); pointer += PUBLISHER_DATA_MANIFESTURL_LEN; return true; @@ -653,7 +657,7 @@ bool UninstallApp(wstring selfFilePath, UninstallerData_t* uninstallerData) void PrintError(wstring message) { - ShowWindow(GetConsoleWindow(), SW_SHOW); + // ShowWindow(GetConsoleWindow(), SW_SHOW); wcerr << message << endl; system("pause"); } \ No newline at end of file diff --git a/Onova.Installer/unzip.cpp b/Onova.Installer/unzip.cpp index 38cbd12..699d97d 100644 --- a/Onova.Installer/unzip.cpp +++ b/Onova.Installer/unzip.cpp @@ -4189,7 +4189,8 @@ ZRESULT TUnzip::Unzip(int index,void *dst,unsigned int len,DWORD flags) if (res>0) {DWORD writ; BOOL bres=WriteFile(h,unzbuf,res,&writ,NULL); if (!bres) {haderr=ZR_WRITE; break;}} #endif if (reached_eof) break; - if (res==0) {haderr=ZR_FLATE; break;} + // if (res==0) {haderr=ZR_FLATE; break;} + if (res == 0) break; // allow empty files } unzCloseCurrentFile(uf); #ifdef ZIP_STD diff --git a/Onova.Publisher.nuspec b/Onova.Publisher.nuspec index f9cc7e0..1168f50 100644 --- a/Onova.Publisher.nuspec +++ b/Onova.Publisher.nuspec @@ -16,6 +16,7 @@ * FIX: Fixed order of versions placed in manifest during rebuild. +* FIX: Fixed installing zips with empty files. * NEW: Added Unicode support for the application name. * NEW: Code signing support using -s or --sign. Read more in Onova.Publisher -h. * CHANGE: Output argument -o or --output will now output generated files to the specified directory. (previously it would always create OnovaPublish folder) @@ -23,6 +24,6 @@ - + \ No newline at end of file diff --git a/Onova.Publisher/Onova.Publisher.csproj b/Onova.Publisher/Onova.Publisher.csproj index 9b2134b..302ca51 100644 --- a/Onova.Publisher/Onova.Publisher.csproj +++ b/Onova.Publisher/Onova.Publisher.csproj @@ -36,11 +36,19 @@ - + + + + + + + + +