From 749ebacebd98ad17c9d7c636f9d90534a691a2bc Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 28 Feb 2017 22:15:54 +0000 Subject: 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 --- src/common/download.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/common') 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; } -- cgit v1.2.3