Skip to content

Commit

Permalink
Fix #17579 - Use guid to make temp file name for zip file
Browse files Browse the repository at this point in the history
QTemporaryFile doesn't work here with QgsZipUtils on Windows for some
reason but is fine on Linux.  Yay development!
  • Loading branch information
NathanW2 committed Dec 17, 2017
1 parent b59bd94 commit 7f474a0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/core/qgsarchive.cpp
Expand Up @@ -22,6 +22,9 @@
#include "qgsauxiliarystorage.h"
#include <iostream>

#include <QStandardPaths>
#include <QUuid>

QgsArchive::QgsArchive()
: mDir( new QTemporaryDir() )
{
Expand Down Expand Up @@ -54,10 +57,9 @@ void QgsArchive::clear()

bool QgsArchive::zip( const QString &filename )
{
// create a temporary path
QTemporaryFile tmpFile;
tmpFile.open();
tmpFile.close();
QString tempPath = QStandardPaths::standardLocations( QStandardPaths::TempLocation ).at( 0 );
QString uuid = QUuid::createUuid().toString();
QFile tmpFile( tempPath + QDir::separator() + uuid );

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

// keep the zip filename
tmpFile.setAutoRemove( false );

return true;
}

Expand Down

0 comments on commit 7f474a0

Please sign in to comment.