mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2025-01-12 20:52:38 -03:00
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
1 changed files with 8 additions and 0 deletions
|
@ -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 a new issue