Skip to content

Commit

Permalink
QMiniz: Only close if we succeded to open it
Browse files Browse the repository at this point in the history
.
  • Loading branch information
MrStevns committed Nov 28, 2024
1 parent 87007c5 commit 85b43e6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions core_lib/src/qminiz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ Status MiniZ::compressFolder(QString zipFilePath, QString srcFolderPath, const Q
mz_zip_zero_struct(mz);

mz_bool ok = mz_zip_writer_init_file(mz, zipFilePath.toUtf8().data(), 0);
ScopeGuard mzScopeGuard2([&] {
mz_zip_writer_end(mz);
});

if (!ok)
{
mz_zip_error err = mz_zip_get_last_error(mz);
dd << QString("Error: Failed to init writer. Error code: %1, reason: %2").arg(static_cast<int>(err)).arg(mz_zip_get_error_string(err));
return Status(Status::FAIL, dd);
}
ScopeGuard mzScopeGuard2([&] {
mz_zip_writer_end(mz);
});

// Add special uncompressed mimetype file to help with the identification of projects
{
Expand Down Expand Up @@ -172,15 +172,14 @@ Status MiniZ::uncompressFolder(QString zipFilePath, QString destPath)
mz_zip_zero_struct(mz);

mz_bool ok = mz_zip_reader_init_file(mz, zipFilePath.toUtf8().data(), 0);
ScopeGuard mzScopeGuard2([&] {
mz_zip_reader_end(mz);
});

if (!ok) {
mz_zip_error err = mz_zip_get_last_error(mz);
dd << QString("Error: Failed to init reader. Error code: %1, reason: %2").arg(static_cast<int>(err)).arg(mz_zip_get_error_string(err));
return Status(Status::FAIL, dd);
}
ScopeGuard mzScopeGuard2([&] {
mz_zip_reader_end(mz);
});

int num = mz_zip_reader_get_num_files(mz);

Expand Down

0 comments on commit 85b43e6

Please sign in to comment.