diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-02-28 22:15:54 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-03-05 16:59:32 +0000 |
commit | 749ebacebd98ad17c9d7c636f9d90534a691a2bc (patch) | |
tree | f2633bd8985f698b996549e1dcf6b79f9d9e2263 | |
parent | download: give download threads distinct names (diff) | |
download | monero-749ebacebd98ad17c9d7c636f9d90534a691a2bc.tar.xz |
download: check available disk space before downloading
We don't check *while* the download happens, so it might
still be that we don't have enough space later
-rw-r--r-- | src/common/download.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/download.cpp b/src/common/download.cpp index b2f95b21a..28aac5a59 100644 --- a/src/common/download.cpp +++ b/src/common/download.cpp @@ -95,6 +95,14 @@ namespace tools { MINFO("Content-Length: " << length); content_length = length; + boost::filesystem::path path(control->path); + boost::filesystem::space_info si = boost::filesystem::space(path); + if (si.available < (size_t)content_length) + { + const uint64_t avail = (si.available + 1023) / 1024, needed = (content_length + 1023) / 1024; + MERROR("Not enough space to download " << needed << " kB to " << path << " (" << avail << " kB available)"); + return false; + } } return true; } |