diff --git a/src/qtgui/confgui/confguiindex.cpp b/src/qtgui/confgui/confguiindex.cpp index a915b9a4..d2af32f6 100644 --- a/src/qtgui/confgui/confguiindex.cpp +++ b/src/qtgui/confgui/confguiindex.cpp @@ -32,6 +32,7 @@ #include #include #include +#include using std::vector; using std::set; using std::string; @@ -43,6 +44,8 @@ using std::string; #include "rcldb.h" #include "execmd.h" #include "rclconfig.h" +#include "webstore.h" +#include "circache.h" static const int spacing = 3; static const int margin = 3; @@ -353,8 +356,12 @@ bool ConfIndexW::setupWebHistoryPanel(int idx) "file (only waste space at the end)." ), -1, 1000*1000); // Max 1TB... m_w->enableLink(bparam, cparam); + int64_t sz = -1; + auto ws = std::unique_ptr(new WebStore(m_rclconf)); + sz = ws->cc()->size(); m_w->addBlurb(idx, tr("Note: old pages will be erased to make space for " - "new ones when the maximum size is reached")); + "new ones when the maximum size is reached. " + "Current size: %1").arg(u8s2qs(displayableBytes(sz)))); m_w->endOfList(idx); return true; } diff --git a/src/utils/circache.cpp b/src/utils/circache.cpp index 261a65ca..a5e29b57 100644 --- a/src/utils/circache.cpp +++ b/src/utils/circache.cpp @@ -787,6 +787,29 @@ bool CirCache::open(OpMode mode) return m_d->readfirstblock(); } +int64_t CirCache::size() +{ + if (m_d == 0) { + LOGERR("CirCache::open: null data\n"); + return -1; + } + struct stat st; + if (m_d->m_fd < 0) { + if (stat(m_d->datafn(m_dir).c_str(), &st) < 0) { + m_d->m_reason << "CirCache::size: stat(" << m_d->datafn(m_dir) << + ") failed " << "errno " << errno; + return -1; + } + } else { + if (fstat(m_d->m_fd, &st) < 0) { + m_d->m_reason << "CirCache::open: fstat(" << m_d->datafn(m_dir) << + ") failed " << "errno " << errno; + return -1; + } + } + return st.st_size; +} + class CCScanHookDump : public CCScanHook { public: virtual status takeone(int64_t offs, const string& udi, diff --git a/src/utils/circache.h b/src/utils/circache.h index 7f98817c..98a0c48d 100644 --- a/src/utils/circache.h +++ b/src/utils/circache.h @@ -37,8 +37,7 @@ */ #include -#include - +#include #include class ConfSimple; @@ -63,6 +62,8 @@ public: enum OpMode {CC_OPREAD, CC_OPWRITE}; virtual bool open(OpMode mode); + virtual int64_t size(); + virtual std::string getpath(); // Set data to 0 if you just want the header