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
pull/95/head
moneromooo-monero 7 years ago
parent f36c5f1e08
commit 749ebacebd
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

@ -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;
}

Loading…
Cancel
Save