Fixed: Exception handling for faulty net download/upload speed

This commit is contained in:
aristocratos 2021-09-30 22:49:14 +02:00
parent d226e6199f
commit 304b9af4e8
1 changed files with 4 additions and 1 deletions

View File

@ -1007,7 +1007,10 @@ namespace Net {
auto& saved_stat = net.at(iface).stat.at(dir);
auto& bandwidth = net.at(iface).bandwidth.at(dir);
const uint64_t val = max((uint64_t)stoul(readfile(sys_file, "0")), saved_stat.last);
uint64_t val = saved_stat.last;
try { val = max((uint64_t)stoul(readfile(sys_file, "0")), val); }
catch (const std::invalid_argument&) {}
catch (const std::out_of_range&) {}
//? Update speed, total and top values
saved_stat.speed = round((double)(val - saved_stat.last) / ((double)(new_timestamp - timestamp) / 1000));