Permalink
Browse files

Q: Half implemented queue cleanup

  • Loading branch information...
pbeckingham committed May 13, 2018
1 parent 8c6c907 commit 57ba5f38eebd6eea1a71bb5ad3e8525c72bccd8e
Showing with 27 additions and 0 deletions.
  1. +26 −0 src/Q.cpp
  2. +1 −0 src/Q.h
@@ -26,6 +26,7 @@

#include <cmake.h>
#include <Q.h>
#include <Datetime.h>
#include <shared.h>
#include <sstream>
#include <iomanip>
@@ -201,3 +202,28 @@ std::vector <std::string> Q::events (const std::string& path) const
}

////////////////////////////////////////////////////////////////////////////////
// Scans the queue for events to remove.
int Q::cleanup () const
{
// Count the removals.
int count = 0;

// Calculate epoch 30 days ago.
Datetime now;
now -= 30 * 86400;
auto one_month_ago = now.toEpoch ();

for (const auto& entry : archive ())
{
File item (entry);
if (item.mtime () < one_month_ago)
{
//item.remove ();
++count;
}
}

return count;
}

////////////////////////////////////////////////////////////////////////////////
@@ -41,6 +41,7 @@ class Q
bool destroy (bool force = false);
bool scan (std::string&);
void post (const std::string&) const;
int cleanup () const;

std::string activateEvent (const std::string&) const;
void archiveEvent (const std::string&) const;

0 comments on commit 57ba5f3

Please sign in to comment.