Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a02d15e

Browse files
nirvngithub-actions[bot]
authored andcommittedMar 14, 2023
[api] Add a new QgsZipUtils::unzip() parameter to skip consistency check
1 parent 5da9cd2 commit a02d15e

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed
 

‎python/core/auto_generated/qgsziputils.sip.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ extension, ``False`` otherwise.
2525
:return: ``True`` if the file is zipped, ``False`` otherwise
2626
%End
2727

28-
bool unzip( const QString &zip, const QString &dir, QStringList &files /Out/ );
28+
bool unzip( const QString &zip, const QString &dir, QStringList &files /Out/, bool checkConsistency = true );
2929
%Docstring
3030
Unzip a zip file in an output directory.
3131

3232
:param zip: The zip filename
3333
:param dir: The output directory
34+
:param checkConsistency: Perform additional stricter consistency checks on the archive, and error if they fail (since QGIS 3.30)
3435

3536
:return: - ``False`` if the zip filename does not exist, the output directory
3637
- files: The absolute path of unzipped files

‎src/core/qgsziputils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool QgsZipUtils::isZipFile( const QString &filename )
3434
return QFileInfo( filename ).suffix().compare( QLatin1String( "qgz" ), Qt::CaseInsensitive ) == 0;
3535
}
3636

37-
bool QgsZipUtils::unzip( const QString &zipFilename, const QString &dir, QStringList &files )
37+
bool QgsZipUtils::unzip( const QString &zipFilename, const QString &dir, QStringList &files, bool checkConsistency )
3838
{
3939
files.clear();
4040

@@ -66,7 +66,7 @@ bool QgsZipUtils::unzip( const QString &zipFilename, const QString &dir, QString
6666

6767
int rc = 0;
6868
const QByteArray fileNamePtr = zipFilename.toUtf8();
69-
struct zip *z = zip_open( fileNamePtr.constData(), ZIP_CHECKCONS, &rc );
69+
struct zip *z = zip_open( fileNamePtr.constData(), checkConsistency ? ZIP_CHECKCONS : 0, &rc );
7070

7171
if ( rc == ZIP_ER_OK && z )
7272
{

‎src/core/qgsziputils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ namespace QgsZipUtils
4242
* \param zip The zip filename
4343
* \param dir The output directory
4444
* \param files The absolute path of unzipped files
45+
* \param checkConsistency Perform additional stricter consistency checks on the archive, and error if they fail (since QGIS 3.30)
4546
* \returns FALSE if the zip filename does not exist, the output directory
4647
* does not exist or is not writable.
4748
* \since QGIS 3.0
4849
*/
49-
CORE_EXPORT bool unzip( const QString &zip, const QString &dir, QStringList &files SIP_OUT );
50+
CORE_EXPORT bool unzip( const QString &zip, const QString &dir, QStringList &files SIP_OUT, bool checkConsistency = true );
5051

5152
/**
5253
* Zip the list of files in the zip file. If the zip file already exists or is

0 commit comments

Comments
 (0)
Please sign in to comment.