aboutsummaryrefslogtreecommitdiff
path: root/src/common/download.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-02-28 22:15:54 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-03-05 16:59:32 +0000
commit749ebacebd98ad17c9d7c636f9d90534a691a2bc (patch)
treef2633bd8985f698b996549e1dcf6b79f9d9e2263 /src/common/download.cpp
parentdownload: give download threads distinct names (diff)
downloadmonero-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
Diffstat (limited to 'src/common/download.cpp')
-rw-r--r--src/common/download.cpp8
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;
}