web indexing prefs: display the current cache size

This commit is contained in:
Jean-Francois Dockes
2021-03-23 10:51:14 +01:00
parent ce6c0edc91
commit 5e82af9798
3 changed files with 34 additions and 3 deletions
+23
View File
@@ -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,
+3 -2
View File
@@ -37,8 +37,7 @@
*/
#include <sys/types.h>
#include <stdint.h>
#include <cstdint>
#include <string>
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