From f31a213738aceedab612650234bcf34b807bcb42 Mon Sep 17 00:00:00 2001 From: zhrenqiang Date: Fri, 15 Nov 2024 20:28:03 +0800 Subject: [PATCH] fix: unzip errcode 900002 Signed-off-by: zhrenqiang Change-Id: I7fba4c1c3618eb1a0a7cd8daaf5276ad0f8c96f1 --- interfaces/kits/cj/src/cj_zip.cpp | 4 ++++ interfaces/kits/js/zip/src/zip.cpp | 4 ++++ interfaces/kits/js/zip/src/zip_reader.cpp | 4 +--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/interfaces/kits/cj/src/cj_zip.cpp b/interfaces/kits/cj/src/cj_zip.cpp index ae8d9d427..67ec13646 100644 --- a/interfaces/kits/cj/src/cj_zip.cpp +++ b/interfaces/kits/cj/src/cj_zip.cpp @@ -244,6 +244,10 @@ ErrCode UnzipWithFilterAndWriters(const PlatformFile &srcFile, FilePath &destDir } } else { std::unique_ptr writer = writerFactory(destDir, entryPath); + if (!writer->PrepareOutput()) { + APP_LOGE("PrepareOutput err"); + return ERR_ZLIB_DEST_FILE_DISABLED; + } if (!reader.ExtractCurrentEntry(writer.get(), std::numeric_limits::max())) { APP_LOGI("Failed to extract"); return ERR_ZLIB_SRC_FILE_FORMAT_ERROR; diff --git a/interfaces/kits/js/zip/src/zip.cpp b/interfaces/kits/js/zip/src/zip.cpp index 23c25d0d1..b0dc97874 100644 --- a/interfaces/kits/js/zip/src/zip.cpp +++ b/interfaces/kits/js/zip/src/zip.cpp @@ -268,6 +268,10 @@ ErrCode UnzipWithFilterAndWriters(const PlatformFile &srcFile, FilePath &destDir } } else { std::unique_ptr writer = writerFactory(destDir, entryPath); + if (!writer->PrepareOutput()) { + APP_LOGE("PrepareOutput err"); + return ERR_ZLIB_DEST_FILE_DISABLED; + } if (!reader.ExtractCurrentEntry(writer.get(), std::numeric_limits::max())) { APP_LOGI("Failed to extract"); return ERR_ZLIB_SRC_FILE_FORMAT_ERROR; diff --git a/interfaces/kits/js/zip/src/zip_reader.cpp b/interfaces/kits/js/zip/src/zip_reader.cpp index ced956c62..53a2850a6 100755 --- a/interfaces/kits/js/zip/src/zip_reader.cpp +++ b/interfaces/kits/js/zip/src/zip_reader.cpp @@ -191,9 +191,7 @@ bool ZipReader::ExtractCurrentEntry(WriterDelegate *delegate, uint64_t numBytesT } const int openResult = unzOpenCurrentFile(zipFile_); if (openResult != UNZ_OK) { - return false; - } - if (!delegate->PrepareOutput()) { + APP_LOGE("unzOpen err %{public}d", openResult); return false; } auto buf = std::make_unique(kZipBufSize);