Skip to content

Commit

Permalink
[OGR provider] (Presumably) fix opening of GeoPackage from network sh…
Browse files Browse the repository at this point in the history
…are on Windows with GDAL >= 3.4.2 (fixes #48003)
  • Loading branch information
rouault authored and nyalldawson committed Apr 4, 2022
1 parent c7b9202 commit cf0af09
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -3484,7 +3484,7 @@ void QgsOgrProvider::open( OpenMode mode )
// Hack use for qgsofflineediting / https://github.com/qgis/QGIS/issues/48012
forceWAL = true;
}
if ( bIsGpkg && mode == OpenModeInitial && !forceWAL )
if ( bIsGpkg && mode == OpenModeInitial && !forceWAL && QgsOgrProviderUtils::IsLocalFile( mFilePath ) )
{
// A hint to QgsOgrProviderUtils::GDALOpenWrapper() to not force WAL
// as in OpenModeInitial we are not going to do anything besides getting capabilities
Expand Down Expand Up @@ -3613,7 +3613,7 @@ void QgsOgrProvider::open( OpenMode mode )
( mGDALDriverName == QLatin1String( "ESRI Shapefile" ) ||
mGDALDriverName == QLatin1String( "MapInfo File" )
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3,4,2)
|| ( !forceWAL && mGDALDriverName == QLatin1String( "GPKG" ) )
|| ( !forceWAL && mGDALDriverName == QLatin1String( "GPKG" ) && QgsOgrProviderUtils::IsLocalFile( mFilePath ) )
#endif
) )
{
Expand Down
4 changes: 1 addition & 3 deletions src/core/providers/ogr/qgsogrproviderutils.cpp
Expand Up @@ -47,8 +47,6 @@ email : nyall dot dawson at gmail dot com

///@cond PRIVATE

static bool IsLocalFile( const QString &path );

#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
Q_GLOBAL_STATIC_WITH_ARGS( QMutex, sGlobalMutex, ( QMutex::Recursive ) )
#else
Expand Down Expand Up @@ -1124,7 +1122,7 @@ GDALDatasetH QgsOgrProviderUtils::GDALOpenWrapper( const char *pszPath, bool bUp
return hDS;
}

static bool IsLocalFile( const QString &path )
bool QgsOgrProviderUtils::IsLocalFile( const QString &path )
{
QString dirName( QFileInfo( path ).absolutePath() );
// Start with the OS specific methods since the QT >= 5.4 method just
Expand Down
3 changes: 3 additions & 0 deletions src/core/providers/ogr/qgsogrproviderutils.h
Expand Up @@ -134,6 +134,9 @@ class CORE_EXPORT QgsOgrProviderUtils
static QStringList directoryExtensions();
static QStringList wildcards();

//! Whether the file is a local file.
static bool IsLocalFile( const QString &path );

/**
* Creates an empty data source
* \param uri location to store the file(s)
Expand Down

0 comments on commit cf0af09

Please sign in to comment.