Skip to content
Permalink
Browse files

Merge pull request #36741 from olivierdalang/geopackages_network

improve geopackage support when opened through networks drives
  • Loading branch information
m-kuhn committed Jun 17, 2020
2 parents 4b5a63d + 096c803 commit 0b92727ebaaf4610d27c7a2efa712a0302d78752
Showing with 10 additions and 2 deletions.
  1. +10 −2 src/core/providers/ogr/qgsogrprovider.cpp
@@ -4020,8 +4020,10 @@ GDALDatasetH QgsOgrProviderUtils::GDALOpenWrapper( const char *pszPath, bool bUp
}

QString filePath( QString::fromUtf8( pszPath ) );

bool bIsGpkg = QFileInfo( filePath ).suffix().compare( QLatin1String( "gpkg" ), Qt::CaseInsensitive ) == 0;
bool bIsLocalGpkg = false;
if ( QFileInfo( filePath ).suffix().compare( QLatin1String( "gpkg" ), Qt::CaseInsensitive ) == 0 &&
if ( bIsGpkg &&
IsLocalFile( filePath ) &&
!CPLGetConfigOption( "OGR_SQLITE_JOURNAL", nullptr ) &&
QgsSettings().value( QStringLiteral( "qgis/walForSqlite3" ), true ).toBool() )
@@ -4034,6 +4036,12 @@ GDALDatasetH QgsOgrProviderUtils::GDALOpenWrapper( const char *pszPath, bool bUp
CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "WAL" );
bIsLocalGpkg = true;
}
else if ( bIsGpkg )
{
// If WAL isn't set, we explicitely disable it, as it is persistent and it
// may have been set on a previous connection.
CPLSetThreadLocalConfigOption( "OGR_SQLITE_JOURNAL", "DELETE" );
}

bool modify_OGR_GPKG_FOREIGN_KEY_CHECK = !CPLGetConfigOption( "OGR_GPKG_FOREIGN_KEY_CHECK", nullptr );
if ( modify_OGR_GPKG_FOREIGN_KEY_CHECK )
@@ -4076,7 +4084,7 @@ static bool IsLocalFile( const QString &path )
// Start with the OS specific methods since the QT >= 5.4 method just
// return a string and not an enumerated type.
#if defined(Q_OS_WIN)
if ( dirName.startsWith( "\\\\" ) )
if ( dirName.startsWith( "\\\\" ) || dirName.startsWith( "//" ) )
return false;
if ( dirName.length() >= 3 && dirName[1] == ':' &&
( dirName[2] == '\\' || dirName[2] == '/' ) )

0 comments on commit 0b92727

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