diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-10-25 16:08:14 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2017-10-25 16:08:14 -0700 |
commit | 2cc4dc5a6fb815f97614c71429d5c4674576ebef (patch) | |
tree | 45542149d0c94cf5a77cf69b42694864edf2bc86 /osdep | |
parent | fac7dc9c913a94550692c31ca6c24fa4db5b5b52 (diff) | |
download | infinitytier-2cc4dc5a6fb815f97614c71429d5c4674576ebef.tar.gz infinitytier-2cc4dc5a6fb815f97614c71429d5c4674576ebef.zip |
Clean peers.d periodically and delete peers older than 30 days.
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/OSUtils.cpp | 6 | ||||
-rw-r--r-- | osdep/OSUtils.hpp | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/osdep/OSUtils.cpp b/osdep/OSUtils.cpp index 30349285..0257458a 100644 --- a/osdep/OSUtils.cpp +++ b/osdep/OSUtils.cpp @@ -133,7 +133,7 @@ std::vector<std::string> OSUtils::listDirectory(const char *path,bool includeDir return r; } -long OSUtils::cleanDirectory(const char *path,const uint64_t olderThan) +long OSUtils::cleanDirectory(const char *path,const int64_t olderThan) { long cleaned = 0; @@ -150,7 +150,7 @@ long OSUtils::cleanDirectory(const char *path,const uint64_t olderThan) date.LowPart = ffd.ftLastWriteTime.dwLowDateTime; if (date.QuadPart > 0) { date.QuadPart -= adjust.QuadPart; - if ((uint64_t)((date.QuadPart / 10000000) * 1000) < olderThan) { + if ((int64_t)((date.QuadPart / 10000000) * 1000) < olderThan) { ztsnprintf(tmp, sizeof(tmp), "%s\\%s", path, ffd.cFileName); if (DeleteFileA(tmp)) ++cleaned; @@ -176,7 +176,7 @@ long OSUtils::cleanDirectory(const char *path,const uint64_t olderThan) if ((strcmp(dptr->d_name,"."))&&(strcmp(dptr->d_name,".."))&&(dptr->d_type == DT_REG)) { ztsnprintf(tmp,sizeof(tmp),"%s/%s",path,dptr->d_name); if (stat(tmp,&st) == 0) { - uint64_t mt = (uint64_t)(st.st_mtime); + int64_t mt = (int64_t)(st.st_mtime); if ((mt > 0)&&((mt * 1000) < olderThan)) { if (unlink(tmp) == 0) ++cleaned; diff --git a/osdep/OSUtils.hpp b/osdep/OSUtils.hpp index 8f66f850..45770b7f 100644 --- a/osdep/OSUtils.hpp +++ b/osdep/OSUtils.hpp @@ -142,7 +142,7 @@ public: * @param olderThan Last modified older than timestamp (ms since epoch) * @return Number of cleaned files or negative on fatal error */ - static long cleanDirectory(const char *path,const uint64_t olderThan); + static long cleanDirectory(const char *path,const int64_t olderThan); /** * Delete a directory and all its files and subdirectories recursively |