Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Temporary .qgs files are deleted
  • Loading branch information
pblottiere committed Jul 31, 2017
1 parent a0a2f0c commit 1d8574e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
7 changes: 7 additions & 0 deletions python/core/qgsarchive.sip
Expand Up @@ -136,6 +136,13 @@ class QgsProjectArchive : QgsArchive
Returns the current .qgs project file or an empty string if there's none
:rtype: str
%End

bool clearProjectFile();
%Docstring
Remove the current .qgs project file from the temporary directory.
:return: true if the file is well removed, false otherwise
:rtype: bool
%End
};

/************************************************************************
Expand Down
14 changes: 14 additions & 0 deletions src/core/qgsarchive.cpp
Expand Up @@ -152,3 +152,17 @@ bool QgsProjectArchive::unzip( const QString &filename )
else
return false;
}

bool QgsProjectArchive::clearProjectFile()
{
bool rc = false;
QString file = projectFile();

if ( !file.isEmpty() && QFile::exists( file ) )
rc = QFile::remove( file );

if ( rc )
mFiles.removeOne( file );

return rc;
}
6 changes: 6 additions & 0 deletions src/core/qgsarchive.h
Expand Up @@ -147,6 +147,12 @@ class CORE_EXPORT QgsProjectArchive : public QgsArchive
* Returns the current .qgs project file or an empty string if there's none
*/
QString projectFile() const;

/**
* Remove the current .qgs project file from the temporary directory.
* \returns true if the file is well removed, false otherwise
*/
bool clearProjectFile();
};

#endif
8 changes: 3 additions & 5 deletions src/core/qgsproject.cpp
Expand Up @@ -2110,17 +2110,18 @@ bool QgsProject::unzip( const QString &filename )
return false;
}

// keep the archive
// keep the archive and remove the temporary .qgs file
mUnzipping = false;
mPathResolverBaseName = QString();
mArchive.reset( archive.release() );
mArchive->clearProjectFile();

return true;
}

bool QgsProject::zip()
{
if ( unzipped() )
if ( !mArchive->filename().isEmpty() )
return zip( mArchive->filename() );

return false;
Expand Down Expand Up @@ -2168,9 +2169,6 @@ bool QgsProject::zip( const QString &filename )
return false;
}

// keep the archive
mArchive.reset( archive.release() );

return true;
}

Expand Down

0 comments on commit 1d8574e

Please sign in to comment.