30
30
31
31
const QRegularExpression QgsLandingPageUtils::PROJECT_HASH_RE { QStringLiteral ( " /(?<projectHash>[a-f0-9]{32})" ) };
32
32
QMap<QString, QString> QgsLandingPageUtils::AVAILABLE_PROJECTS;
33
- QString QgsLandingPageUtils::QGIS_SERVER_PROJECTS_DIRECTORIES;
34
- QString QgsLandingPageUtils::QGIS_SERVER_PROJECTS_PG_CONNECTIONS;
35
33
36
34
std::once_flag initDirWatcher;
37
35
38
36
QMap<QString, QString> QgsLandingPageUtils::projects ( )
39
37
{
40
38
39
+ static QString QGIS_SERVER_PROJECTS_DIRECTORIES;
40
+ static QString QGIS_SERVER_PROJECTS_PG_CONNECTIONS;
41
+
41
42
// Init directory watcher
42
43
static QFileSystemWatcher dirWatcher;
43
44
std::call_once ( initDirWatcher, [ = ]
@@ -53,9 +54,9 @@ QMap<QString, QString> QgsLandingPageUtils::projects( )
53
54
const QString projectDir { QString ( qgetenv ( " QGIS_SERVER_PROJECTS_DIRECTORIES" ) ) };
54
55
55
56
// Clear cache if QGIS_SERVER_PROJECTS_DIRECTORIES has changed
56
- if ( projectDir != QgsLandingPageUtils:: QGIS_SERVER_PROJECTS_DIRECTORIES )
57
+ if ( projectDir != QGIS_SERVER_PROJECTS_DIRECTORIES )
57
58
{
58
- QgsLandingPageUtils:: QGIS_SERVER_PROJECTS_DIRECTORIES = projectDir;
59
+ QGIS_SERVER_PROJECTS_DIRECTORIES = projectDir;
59
60
AVAILABLE_PROJECTS.clear ();
60
61
const QStringList cWatchedDirs { dirWatcher.directories () };
61
62
dirWatcher.removePaths ( cWatchedDirs );
@@ -64,16 +65,17 @@ QMap<QString, QString> QgsLandingPageUtils::projects( )
64
65
const QString pgConnections { QString ( qgetenv ( " QGIS_SERVER_PROJECTS_PG_CONNECTIONS" ) ) };
65
66
66
67
// 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 )
68
69
{
69
- QgsLandingPageUtils:: QGIS_SERVER_PROJECTS_PG_CONNECTIONS = pgConnections;
70
+ QGIS_SERVER_PROJECTS_PG_CONNECTIONS = pgConnections;
70
71
AVAILABLE_PROJECTS.clear ();
71
72
}
72
73
73
74
// Scan QGIS_SERVER_PROJECTS_DIRECTORIES
74
75
if ( AVAILABLE_PROJECTS.isEmpty () )
75
76
{
76
- for ( const auto &path : projectDir.split ( QStringLiteral ( " ||" ) ) )
77
+ const auto cProjectDirs { projectDir.split ( QStringLiteral ( " ||" ) ) };
78
+ for ( const auto &path : cProjectDirs )
77
79
{
78
80
if ( ! path.isEmpty () )
79
81
{
@@ -109,7 +111,8 @@ QMap<QString, QString> QgsLandingPageUtils::projects( )
109
111
// PG projects (there is no watcher for PG: scan every time)
110
112
const auto storage { QgsApplication::instance ()->projectStorageRegistry ()->projectStorageFromType ( QStringLiteral ( " postgresql" ) ) };
111
113
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 )
113
116
{
114
117
if ( ! connectionString.isEmpty () )
115
118
{
0 commit comments