add default webinterface path for snap environment
fix settings path double slash
This commit is contained in:
parent
edc3188077
commit
d2bfd0e11f
@ -99,7 +99,7 @@ GuhConfiguration::GuhConfiguration(QObject *parent) :
|
||||
insecureConfig.port = 80;
|
||||
insecureConfig.sslEnabled = false;
|
||||
insecureConfig.authenticationEnabled = false;
|
||||
insecureConfig.publicFolder = "/usr/share/guh-webinterface/public/";
|
||||
insecureConfig.publicFolder = defaultWebserverPublicFolderPath();
|
||||
m_webServerConfigs[insecureConfig.id] = insecureConfig;
|
||||
storeWebServerConfig(insecureConfig);
|
||||
|
||||
@ -109,7 +109,7 @@ GuhConfiguration::GuhConfiguration(QObject *parent) :
|
||||
secureConfig.port = 443;
|
||||
secureConfig.sslEnabled = true;
|
||||
secureConfig.authenticationEnabled = false;
|
||||
secureConfig.publicFolder = "/usr/share/guh-webinterface/public/";
|
||||
secureConfig.publicFolder = defaultWebserverPublicFolderPath();
|
||||
m_webServerConfigs[secureConfig.id] = secureConfig;
|
||||
storeWebServerConfig(secureConfig);
|
||||
}
|
||||
@ -326,6 +326,18 @@ void GuhConfiguration::setServerUuid(const QUuid &uuid)
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
QString GuhConfiguration::defaultWebserverPublicFolderPath() const
|
||||
{
|
||||
QString publicFolderPath;
|
||||
if (!qgetenv("SNAP").isEmpty()) {
|
||||
// FIXME: one could point to sensible data by changing the SNAP env to i.e /etc
|
||||
publicFolderPath = QString(qgetenv("SNAP")) + "/guh-webinterface";
|
||||
} else {
|
||||
publicFolderPath = "/usr/share/guh-webinterface/public/";
|
||||
}
|
||||
return publicFolderPath;
|
||||
}
|
||||
|
||||
void GuhConfiguration::storeServerConfig(const QString &group, const ServerConfiguration &config)
|
||||
{
|
||||
GuhSettings settings(GuhSettings::SettingsRoleGlobal);
|
||||
|
||||
@ -139,6 +139,18 @@ void WebServer::sendHttpReply(HttpReply *reply)
|
||||
socket->write(reply->data());
|
||||
}
|
||||
|
||||
QString WebServer::defaultPublicFolderPath() const
|
||||
{
|
||||
QString publicFolderPath;
|
||||
if (!qgetenv("SNAP").isEmpty()) {
|
||||
publicFolderPath = QString(qgetenv("SNAP")) + "/guh-webinterface";
|
||||
} else {
|
||||
publicFolderPath =
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool WebServer::verifyFile(QSslSocket *socket, const QString &fileName)
|
||||
{
|
||||
QFileInfo file(fileName);
|
||||
|
||||
@ -143,7 +143,7 @@ QString GuhSettings::logPath()
|
||||
return logPath;
|
||||
}
|
||||
|
||||
/*! Returns the path to the folder where the GuhSettings will be saved. */
|
||||
/*! Returns the path to the folder where the GuhSettings will be saved i.e. \tt{/etc/guh}. */
|
||||
QString GuhSettings::settingsPath()
|
||||
{
|
||||
QString path;
|
||||
@ -154,7 +154,7 @@ QString GuhSettings::settingsPath()
|
||||
} else if (organisationName == "guh-test") {
|
||||
path = "/tmp/" + organisationName;
|
||||
} else if (GuhSettings::isRoot()) {
|
||||
path = "/etc/guh/";
|
||||
path = "/etc/guh";
|
||||
} else {
|
||||
path = QDir::homePath() + "/.config/" + organisationName;
|
||||
}
|
||||
@ -171,6 +171,7 @@ QString GuhSettings::translationsPath()
|
||||
}
|
||||
}
|
||||
|
||||
/*! Returns the default system sorage path i.e. \tt{/var/lib/guh}. */
|
||||
QString GuhSettings::storagePath()
|
||||
{
|
||||
QString path;
|
||||
@ -178,11 +179,11 @@ QString GuhSettings::storagePath()
|
||||
if (!qgetenv("SNAP").isEmpty()) {
|
||||
path = QString(qgetenv("SNAP_DATA"));
|
||||
} else if (organisationName == "guh-test") {
|
||||
path = "/tmp/" + organisationName + "/";
|
||||
path = "/tmp/" + organisationName;
|
||||
} else if (GuhSettings::isRoot()) {
|
||||
path = "/var/lib/" + organisationName + "/";
|
||||
path = "/var/lib/" + organisationName;
|
||||
} else {
|
||||
path = QDir::homePath() + "/.local/share/" + organisationName + "/";
|
||||
path = QDir::homePath() + "/.local/share/" + organisationName;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user