Skip to content
Permalink
Browse files

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!
  • Loading branch information
NathanW2 committed Dec 17, 2017
1 parent b59bd94 commit 7f474a097f6289b76e140a4719fa7719cd7d8977
Showing with 6 additions and 7 deletions.
  1. +6 −7 src/core/qgsarchive.cpp
@@ -22,6 +22,9 @@
#include "qgsauxiliarystorage.h"
#include <iostream>

#include <QStandardPaths>
#include <QUuid>

QgsArchive::QgsArchive()
: mDir( new QTemporaryDir() )
{
@@ -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 ) )
@@ -79,9 +81,6 @@ bool QgsArchive::zip( const QString &filename )
return false;
}

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

return true;
}

0 comments on commit 7f474a0

Please sign in to comment.
You can’t perform that action at this time.