!7487 fix: unzip errcode 900002

Merge pull request !7487 from zhrenqiang/ziperr
This commit is contained in:
openharmony_ci 2024-11-22 02:49:31 +00:00 committed by Gitee
commit 9f1854d7ce
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 9 additions and 3 deletions

View File

@ -244,6 +244,10 @@ ErrCode UnzipWithFilterAndWriters(const PlatformFile &srcFile, FilePath &destDir
}
} else {
std::unique_ptr<WriterDelegate> 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<uint64_t>::max())) {
APP_LOGI("Failed to extract");
return ERR_ZLIB_SRC_FILE_FORMAT_ERROR;

View File

@ -268,6 +268,10 @@ ErrCode UnzipWithFilterAndWriters(const PlatformFile &srcFile, FilePath &destDir
}
} else {
std::unique_ptr<WriterDelegate> 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<uint64_t>::max())) {
APP_LOGI("Failed to extract");
return ERR_ZLIB_SRC_FILE_FORMAT_ERROR;

View File

@ -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<char[]>(kZipBufSize);