Skip to content

Commit

Permalink
download: catch exceptions checking for size
Browse files Browse the repository at this point in the history
Happens on at least one windows box
  • Loading branch information
moneromooo-monero committed Nov 26, 2019
1 parent fe3f6a3 commit 3813a99
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/common/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,17 @@ 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)
try
{
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;
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;
}
}
catch (const std::exception &e) { MWARNING("Failed to check for free space: " << e.what()); }
}
if (offset > 0)
{
Expand Down

0 comments on commit 3813a99

Please sign in to comment.