diff options
Diffstat (limited to 'src/protocols/abouthandler.cpp')
| -rw-r--r-- | src/protocols/abouthandler.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/protocols/abouthandler.cpp b/src/protocols/abouthandler.cpp index 4ab789b..784e1bb 100644 --- a/src/protocols/abouthandler.cpp +++ b/src/protocols/abouthandler.cpp @@ -1,5 +1,6 @@ #include "abouthandler.hpp" #include "kristall.hpp" +#include "ioutil.hpp" #include <QUrl> #include <QFile> @@ -48,6 +49,27 @@ bool AboutHandler::startRequest(const QUrl &url, ProtocolHandler::RequestOptions emit this->requestComplete(document, "text/gemini"); } + else if (url.path() == "cache") + { + QByteArray document; + document.append("# Cache information\n"); + + auto& cache = kristall::cache.getPages(); + long unsigned cache_usage = 0; + int cached_count = 0; + for (auto it = cache.begin(); it != cache.end(); ++it, ++cached_count) + { + cache_usage += (long unsigned)it->second->body.size(); + } + + document.append(QString( + "In-memory cache usage:\n" + "* %1 used\n" + "* %2 pages in cache\n") + .arg(IoUtil::size_human(cache_usage), QString::number(cached_count))); + + emit this->requestComplete(document, "text/gemini"); + } else { QFile file(QString(":/about/%1.gemini").arg(url.path())); |
