feat(core,registry): unmount HTTP server prefix on docset removal

This commit is contained in:
Oleg Shparber 2020-01-30 01:29:46 -05:00 committed by Oleg Shparber
parent 6dc75311b4
commit fc1f18f6c5
3 changed files with 15 additions and 0 deletions

View File

@ -90,6 +90,19 @@ QUrl HttpServer::mount(const QString &prefix, const QString &path)
return mountUrl;
}
bool HttpServer::unmount(const QString &prefix)
{
const QString pfx = sanitizePrefix(prefix);
const bool ok = m_server->remove_mount_point(pfx.toUtf8());
if (!ok) {
qCWarning(log, "Failed to unmount '%s' to '%s'.", qPrintable(prefix), qPrintable(pfx));
}
qCDebug(log, "Unmounted prefix '%s' ('%s').", qPrintable(prefix), qPrintable(pfx));
return ok;
}
QString HttpServer::sanitizePrefix(const QString &prefix)
{
QString pfx = (prefix.startsWith(QLatin1String("/")) ? prefix.right(1) : prefix).toLower();

View File

@ -47,6 +47,7 @@ public:
QUrl baseUrl() const;
QUrl mount(const QString &prefix, const QString &path);
bool unmount(const QString &prefix);
private:
static QString sanitizePrefix(const QString &prefix);

View File

@ -166,6 +166,7 @@ void DocsetRegistry::loadDocset(const QString &path)
void DocsetRegistry::unloadDocset(const QString &name)
{
emit docsetAboutToBeUnloaded(name);
Core::Application::instance()->httpServer()->unmount(name);
delete m_docsets.take(name);
emit docsetUnloaded(name);
}