Skip to content

Commit 7f474a0

Browse files
committedDec 17, 2017
Fix #17579 - Use guid to make temp file name for zip file
QTemporaryFile doesn't work here with QgsZipUtils on Windows for some reason but is fine on Linux. Yay development!
1 parent b59bd94 commit 7f474a0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed
 

‎src/core/qgsarchive.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
#include "qgsauxiliarystorage.h"
2323
#include <iostream>
2424

25+
#include <QStandardPaths>
26+
#include <QUuid>
27+
2528
QgsArchive::QgsArchive()
2629
: mDir( new QTemporaryDir() )
2730
{
@@ -54,10 +57,9 @@ void QgsArchive::clear()
5457

5558
bool QgsArchive::zip( const QString &filename )
5659
{
57-
// create a temporary path
58-
QTemporaryFile tmpFile;
59-
tmpFile.open();
60-
tmpFile.close();
60+
QString tempPath = QStandardPaths::standardLocations( QStandardPaths::TempLocation ).at( 0 );
61+
QString uuid = QUuid::createUuid().toString();
62+
QFile tmpFile( tempPath + QDir::separator() + uuid );
6163

6264
// zip content
6365
if ( ! QgsZipUtils::zip( tmpFile.fileName(), mFiles ) )
@@ -79,9 +81,6 @@ bool QgsArchive::zip( const QString &filename )
7981
return false;
8082
}
8183

82-
// keep the zip filename
83-
tmpFile.setAutoRemove( false );
84-
8584
return true;
8685
}
8786

0 commit comments

Comments
 (0)
Please sign in to comment.