Skip to content

Commit a04bbe4

Browse files
committed
Address PR comments
1 parent 3f5e88a commit a04bbe4

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

src/server/services/landingpage/qgslandingpageutils.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030

3131
const QRegularExpression QgsLandingPageUtils::PROJECT_HASH_RE { QStringLiteral( "/(?<projectHash>[a-f0-9]{32})" ) };
3232
QMap<QString, QString> QgsLandingPageUtils::AVAILABLE_PROJECTS;
33-
QString QgsLandingPageUtils::QGIS_SERVER_PROJECTS_DIRECTORIES;
34-
QString QgsLandingPageUtils::QGIS_SERVER_PROJECTS_PG_CONNECTIONS;
3533

3634
std::once_flag initDirWatcher;
3735

3836
QMap<QString, QString> QgsLandingPageUtils::projects( )
3937
{
4038

39+
static QString QGIS_SERVER_PROJECTS_DIRECTORIES;
40+
static QString QGIS_SERVER_PROJECTS_PG_CONNECTIONS;
41+
4142
// Init directory watcher
4243
static QFileSystemWatcher dirWatcher;
4344
std::call_once( initDirWatcher, [ = ]
@@ -53,9 +54,9 @@ QMap<QString, QString> QgsLandingPageUtils::projects( )
5354
const QString projectDir { QString( qgetenv( "QGIS_SERVER_PROJECTS_DIRECTORIES" ) ) };
5455

5556
// Clear cache if QGIS_SERVER_PROJECTS_DIRECTORIES has changed
56-
if ( projectDir != QgsLandingPageUtils::QGIS_SERVER_PROJECTS_DIRECTORIES )
57+
if ( projectDir != QGIS_SERVER_PROJECTS_DIRECTORIES )
5758
{
58-
QgsLandingPageUtils::QGIS_SERVER_PROJECTS_DIRECTORIES = projectDir;
59+
QGIS_SERVER_PROJECTS_DIRECTORIES = projectDir;
5960
AVAILABLE_PROJECTS.clear();
6061
const QStringList cWatchedDirs { dirWatcher.directories() };
6162
dirWatcher.removePaths( cWatchedDirs );
@@ -64,16 +65,17 @@ QMap<QString, QString> QgsLandingPageUtils::projects( )
6465
const QString pgConnections { QString( qgetenv( "QGIS_SERVER_PROJECTS_PG_CONNECTIONS" ) ) };
6566

6667
// Clear cache if QGIS_SERVER_PROJECTS_PG_CONNECTIONS has changed
67-
if ( pgConnections != QgsLandingPageUtils::QGIS_SERVER_PROJECTS_PG_CONNECTIONS )
68+
if ( pgConnections != QGIS_SERVER_PROJECTS_PG_CONNECTIONS )
6869
{
69-
QgsLandingPageUtils::QGIS_SERVER_PROJECTS_PG_CONNECTIONS = pgConnections;
70+
QGIS_SERVER_PROJECTS_PG_CONNECTIONS = pgConnections;
7071
AVAILABLE_PROJECTS.clear();
7172
}
7273

7374
// Scan QGIS_SERVER_PROJECTS_DIRECTORIES
7475
if ( AVAILABLE_PROJECTS.isEmpty() )
7576
{
76-
for ( const auto &path : projectDir.split( QStringLiteral( "||" ) ) )
77+
const auto cProjectDirs { projectDir.split( QStringLiteral( "||" ) ) };
78+
for ( const auto &path : cProjectDirs )
7779
{
7880
if ( ! path.isEmpty() )
7981
{
@@ -109,7 +111,8 @@ QMap<QString, QString> QgsLandingPageUtils::projects( )
109111
// PG projects (there is no watcher for PG: scan every time)
110112
const auto storage { QgsApplication::instance()->projectStorageRegistry()->projectStorageFromType( QStringLiteral( "postgresql" ) ) };
111113
Q_ASSERT( storage );
112-
for ( const auto &connectionString : QString( qgetenv( "QGIS_SERVER_PROJECTS_PG_CONNECTIONS" ) ).split( QStringLiteral( "||" ) ) )
114+
const auto cPgConnections { pgConnections.split( QStringLiteral( "||" ) ) };
115+
for ( const auto &connectionString : cPgConnections )
113116
{
114117
if ( ! connectionString.isEmpty() )
115118
{

src/server/services/landingpage/qgslandingpageutils.h

-10
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ struct QgsLandingPageUtils
7878
*/
7979
static QString projectUriFromUrl( const QString &url );
8080

81-
/**
82-
* Store env configuration parameter, used to invalidate the cache if the value changes
83-
*/
84-
static QString QGIS_SERVER_PROJECTS_DIRECTORIES;
85-
86-
/**
87-
* Store env configuration parameter, used to invalidate the cache if the value changes
88-
*/
89-
static QString QGIS_SERVER_PROJECTS_PG_CONNECTIONS;
90-
9181
};
9282

9383
#endif // QGSLANDINGPAGEUTILS_H
Binary file not shown.

0 commit comments

Comments
 (0)