Skip to content
Permalink
Browse files

remove temporary SSL files only when they were created

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 ed80951db266902a593091894f6e653cc70d484c
Showing with 12 additions and 12 deletions.
  1. +12 −12 src/providers/postgres/qgspostgresconn.cpp
@@ -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 )

0 comments on commit ed80951

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