Skip to content
Permalink
Browse files

Don't show ept-build.json files in browser

  • Loading branch information
nyalldawson committed Nov 5, 2020
1 parent 519222f commit 1225eb498a2ef31a94554b6c3f1b7d816b87e917
@@ -100,6 +100,21 @@ int QgsEptProviderMetadata::priorityForUri( const QString &uri ) const
return 0;
}

bool QgsEptProviderMetadata::uriIsBlocklisted( const QString &uri ) const
{
const QVariantMap parts = decodeUri( uri );
if ( !parts.contains( QStringLiteral( "path" ) ) )
return false;

QFileInfo fi( parts.value( QStringLiteral( "path" ) ).toString() );

// internal details only
if ( fi.fileName().compare( QLatin1String( "ept-build.json" ), Qt::CaseInsensitive ) == 0 )
return true;

return false;
}

QVariantMap QgsEptProviderMetadata::decodeUri( const QString &uri ) const
{
const QString path = uri;
@@ -64,6 +64,7 @@ class QgsEptProviderMetadata : public QgsProviderMetadata
QgsEptProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) override;
QList< QgsDataItemProvider * > dataItemProviders() const override;
int priorityForUri( const QString &uri ) const override;
bool uriIsBlocklisted( const QString &uri ) const override;
QString encodeUri( const QVariantMap &parts ) const override;
QVariantMap decodeUri( const QString &uri ) const override;
QString filters( FilterType type ) override;
@@ -47,6 +47,7 @@ class TestQgsEptProvider : public QObject
void encodeUri();
void decodeUri();
void preferredUri();
void uriIsBlocklisted();

private:
QString mTestDataDir;
@@ -119,6 +120,12 @@ void TestQgsEptProvider::preferredUri()
QVERIFY( QgsProviderRegistry::instance()->shouldDeferUriForOtherProviders( QStringLiteral( "/home/test/ept.json" ), QStringLiteral( "ogr" ) ) );
}

void TestQgsEptProvider::uriIsBlocklisted()
{
QVERIFY( !QgsProviderRegistry::instance()->uriIsBlocklisted( QStringLiteral( "/home/nyall/ept.json" ) ) );
QVERIFY( QgsProviderRegistry::instance()->uriIsBlocklisted( QStringLiteral( "/home/nyall/ept-build.json" ) ) );
}


QGSTEST_MAIN( TestQgsEptProvider )
#include "testqgseptprovider.moc"

0 comments on commit 1225eb4

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