Skip to content

Commit 1d8574e

Browse files
committedJul 31, 2017
Temporary .qgs files are deleted
1 parent a0a2f0c commit 1d8574e

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed
 

‎python/core/qgsarchive.sip

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ class QgsProjectArchive : QgsArchive
136136
Returns the current .qgs project file or an empty string if there's none
137137
:rtype: str
138138
%End
139+
140+
bool clearProjectFile();
141+
%Docstring
142+
Remove the current .qgs project file from the temporary directory.
143+
:return: true if the file is well removed, false otherwise
144+
:rtype: bool
145+
%End
139146
};
140147

141148
/************************************************************************

‎src/core/qgsarchive.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,17 @@ bool QgsProjectArchive::unzip( const QString &filename )
152152
else
153153
return false;
154154
}
155+
156+
bool QgsProjectArchive::clearProjectFile()
157+
{
158+
bool rc = false;
159+
QString file = projectFile();
160+
161+
if ( !file.isEmpty() && QFile::exists( file ) )
162+
rc = QFile::remove( file );
163+
164+
if ( rc )
165+
mFiles.removeOne( file );
166+
167+
return rc;
168+
}

‎src/core/qgsarchive.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ class CORE_EXPORT QgsProjectArchive : public QgsArchive
147147
* Returns the current .qgs project file or an empty string if there's none
148148
*/
149149
QString projectFile() const;
150+
151+
/**
152+
* Remove the current .qgs project file from the temporary directory.
153+
* \returns true if the file is well removed, false otherwise
154+
*/
155+
bool clearProjectFile();
150156
};
151157

152158
#endif

‎src/core/qgsproject.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,17 +2110,18 @@ bool QgsProject::unzip( const QString &filename )
21102110
return false;
21112111
}
21122112

2113-
// keep the archive
2113+
// keep the archive and remove the temporary .qgs file
21142114
mUnzipping = false;
21152115
mPathResolverBaseName = QString();
21162116
mArchive.reset( archive.release() );
2117+
mArchive->clearProjectFile();
21172118

21182119
return true;
21192120
}
21202121

21212122
bool QgsProject::zip()
21222123
{
2123-
if ( unzipped() )
2124+
if ( !mArchive->filename().isEmpty() )
21242125
return zip( mArchive->filename() );
21252126

21262127
return false;
@@ -2168,9 +2169,6 @@ bool QgsProject::zip( const QString &filename )
21682169
return false;
21692170
}
21702171

2171-
// keep the archive
2172-
mArchive.reset( archive.release() );
2173-
21742172
return true;
21752173
}
21762174

0 commit comments

Comments
 (0)
Please sign in to comment.