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
This commit is contained in:
parent
f36c5f1e08
commit
749ebacebd
|
@ -95,6 +95,14 @@ namespace tools
|
||||||
{
|
{
|
||||||
MINFO("Content-Length: " << length);
|
MINFO("Content-Length: " << length);
|
||||||
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue