Skip to content

Commit

Permalink
remove temporary SSL files only when they were created
Browse files Browse the repository at this point in the history
This avoids warnings from QFile::remove(). Also deduplicated the code to remove the temporary files.
  • Loading branch information
SebDieBln committed Jan 17, 2016
1 parent f966c42 commit ed80951
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/providers/postgres/qgspostgresconn.cpp
Expand Up @@ -208,19 +208,19 @@ QgsPostgresConn::QgsPostgresConn( const QString& conninfo, bool readOnly, bool s

mConn = PQconnectdb( expandedConnectionInfo.toLocal8Bit() ); // use what is set based on locale; after connecting, use Utf8

// remove temporary cert/key/CA
// remove temporary cert/key/CA if they exist
QgsDataSourceURI expandedUri( expandedConnectionInfo );
QString sslCertFile = expandedUri.param( "sslcert" );
sslCertFile.remove( "'" );
QFile::remove( sslCertFile );

QString sslKeyFile = expandedUri.param( "sslkey" );
sslKeyFile.remove( "'" );
QFile::remove( sslKeyFile );

QString sslCAFile = expandedUri.param( "sslrootcert" );
sslCAFile.remove( "'" );
QFile::remove( sslCAFile );
QStringList parameters;
parameters << "sslcert" << "sslkey" << "sslrootcert";
Q_FOREACH ( const QString& param, parameters )
{
if ( expandedUri.hasParam( param ) )
{
QString fileName = expandedUri.param( param );
fileName.remove( "'" );
QFile::remove( fileName );
}
}

// check the connection status
if ( PQstatus() != CONNECTION_OK )
Expand Down

0 comments on commit ed80951

Please sign in to comment.