Skip to content

Commit

Permalink
Merge pull request #2686 from SebDieBln/FixPostgresWarnings
Browse files Browse the repository at this point in the history
[Postgres] Remove the temporary SSL files only when they were created
  • Loading branch information
jef-n committed Jan 17, 2016
2 parents f966c42 + ed80951 commit 6435a20
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

1 comment on commit 6435a20

@luipir
Copy link
Contributor

@luipir luipir commented on 6435a20 Jan 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch... thank you

Please sign in to comment.