diff options
author | Sergey Yershov <yershov@corp.mail.ru> | 2016-02-15 13:09:00 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:22:10 +0300 |
commit | 40711bdd078b3bd6ddcbc8965cb074083fdc5baf (patch) | |
tree | 7379774288ab6cc62f8e8d7fc29bb6276ec07eff /platform | |
parent | 796a53ed9755c0d0044f6f32b3767f759e34fd1d (diff) |
[new downloader][MAPSME-121] Add function to check enough space for migrate
Diffstat (limited to 'platform')
-rw-r--r-- | platform/platform.hpp | 1 | ||||
-rw-r--r-- | platform/platform_unix_impl.cpp | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/platform/platform.hpp b/platform/platform.hpp index 127c7c019e..186f3d4c9d 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -168,6 +168,7 @@ public: NOT_ENOUGH_SPACE }; TStorageStatus GetWritableStorageStatus(uint64_t neededSize) const; + uint64_t GetWritableStorageSpace() const; /// @name Functions for concurrent tasks. //@{ diff --git a/platform/platform_unix_impl.cpp b/platform/platform_unix_impl.cpp index e7236d2280..fda11526e4 100644 --- a/platform/platform_unix_impl.cpp +++ b/platform/platform_unix_impl.cpp @@ -199,6 +199,18 @@ Platform::TStorageStatus Platform::GetWritableStorageStatus(uint64_t neededSize) return STORAGE_OK; } +uint64_t Platform::GetWritableStorageSpace() const +{ + struct statfs st; + int const ret = statfs(m_writableDir.c_str(), &st); + + LOG(LDEBUG, ("statfs return = ", ret, + "; block size = ", st.f_bsize, + "; blocks available = ", st.f_bavail)); + + return (ret != 0) ? 0 : st.f_bsize * st.f_bavail; +} + namespace pl { void EnumerateFilesByRegExp(string const & directory, string const & regexp, |