Skip to content

Commit

Permalink
[OGR provider] When creating a new layer with createEmptyLayer(), mak…
Browse files Browse the repository at this point in the history
…e sure the opened datasets do not get reused
  • Loading branch information
rouault authored and nyalldawson committed Nov 23, 2017
1 parent 0a092cc commit e0bdd26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -343,6 +343,8 @@ QgsVectorLayerExporter::ExportError QgsOgrProvider::createEmptyLayer( const QStr
}
}
QgsOgrProviderUtils::invalidateCachedLastModifiedDate( uri );
return QgsVectorLayerExporter::NoError;
}
Expand Down Expand Up @@ -4312,6 +4314,22 @@ static QDateTime getLastModified( const QString &dsName )
return QFileInfo( dsName ).lastModified();
}

// In case we do very fast structural changes within the same second,
// the last modified date might not change enough, so artificially
// decrement the cache modified date, so that the file appears newer to it
void QgsOgrProviderUtils::invalidateCachedLastModifiedDate( const QString &dsName )
{
QMutexLocker locker( &globalMutex );

auto iter = mapDSNameToLastModifiedDate.find( dsName );
if ( iter != mapDSNameToLastModifiedDate.end() )
{
QgsDebugMsg( QString( "invalidating last modified date for %1" ).arg( dsName ) );
iter.value() = iter.value().addSecs( -10 );
}
}


QString QgsOgrProviderUtils::expandAuthConfig( const QString &dsName )
{
QString uri( dsName );
Expand Down
3 changes: 3 additions & 0 deletions src/providers/ogr/qgsogrprovider.h
Expand Up @@ -418,6 +418,9 @@ class QgsOgrProviderUtils

//! Return the string to provide to QgsOgrConnPool::instance() methods
static QString connectionPoolId( const QString &dataSourceURI );

//! Invalidate the cached last modified date of a dataset
static void invalidateCachedLastModifiedDate( const QString &dsName );
};


Expand Down

0 comments on commit e0bdd26

Please sign in to comment.