mirror of
https://github.com/aria2/aria2.git
synced 2024-12-29 14:14:53 +00:00
Rewritten ServerStatMan::load() using nothrow version of parseInt
This commit is contained in:
parent
8f2030da09
commit
f75402739b
@ -196,31 +196,40 @@ bool ServerStatMan::load(const std::string& filename)
|
||||
continue;
|
||||
}
|
||||
SharedHandle<ServerStat> sstat(new ServerStat(m[S_HOST], m[S_PROTOCOL]));
|
||||
try {
|
||||
const std::string& dlSpeed = m[S_DL_SPEED];
|
||||
sstat->setDownloadSpeed(util::parseUInt(dlSpeed));
|
||||
// Old serverstat file doesn't contains SC_AVG_SPEED
|
||||
if(!m[S_SC_AVG_SPEED].empty()) {
|
||||
const std::string& s = m[S_SC_AVG_SPEED];
|
||||
sstat->setSingleConnectionAvgSpeed(util::parseUInt(s));
|
||||
}
|
||||
// Old serverstat file doesn't contains MC_AVG_SPEED
|
||||
if(!m[S_MC_AVG_SPEED].empty()) {
|
||||
const std::string& s = m[S_MC_AVG_SPEED];
|
||||
sstat->setMultiConnectionAvgSpeed(util::parseUInt(s));
|
||||
}
|
||||
// Old serverstat file doesn't contains COUNTER_SPEED
|
||||
if(!m[S_COUNTER].empty()) {
|
||||
const std::string& s = m[S_COUNTER];
|
||||
sstat->setCounter(util::parseUInt(s));
|
||||
}
|
||||
const std::string& lastUpdated = m[S_LAST_UPDATED];
|
||||
sstat->setLastUpdated(Time(util::parseInt(lastUpdated)));
|
||||
sstat->setStatus(m[S_STATUS]);
|
||||
add(sstat);
|
||||
} catch(RecoverableException& e) {
|
||||
|
||||
uint32_t uintval;
|
||||
if(!util::parseUIntNoThrow(uintval, m[S_DL_SPEED])) {
|
||||
continue;
|
||||
}
|
||||
sstat->setDownloadSpeed(uintval);
|
||||
// Old serverstat file doesn't contains SC_AVG_SPEED
|
||||
if(!m[S_SC_AVG_SPEED].empty()) {
|
||||
if(!util::parseUIntNoThrow(uintval, m[S_SC_AVG_SPEED])) {
|
||||
continue;
|
||||
}
|
||||
sstat->setSingleConnectionAvgSpeed(uintval);
|
||||
}
|
||||
// Old serverstat file doesn't contains MC_AVG_SPEED
|
||||
if(!m[S_MC_AVG_SPEED].empty()) {
|
||||
if(!util::parseUIntNoThrow(uintval, m[S_MC_AVG_SPEED])) {
|
||||
continue;
|
||||
}
|
||||
sstat->setMultiConnectionAvgSpeed(uintval);
|
||||
}
|
||||
// Old serverstat file doesn't contains COUNTER_SPEED
|
||||
if(!m[S_COUNTER].empty()) {
|
||||
if(!util::parseUIntNoThrow(uintval, m[S_COUNTER])) {
|
||||
continue;
|
||||
}
|
||||
sstat->setCounter(uintval);
|
||||
}
|
||||
int32_t intval;
|
||||
if(!util::parseIntNoThrow(intval, m[S_LAST_UPDATED])) {
|
||||
continue;
|
||||
}
|
||||
sstat->setLastUpdated(Time(intval));
|
||||
sstat->setStatus(m[S_STATUS]);
|
||||
add(sstat);
|
||||
}
|
||||
A2_LOG_NOTICE(fmt(MSG_SERVER_STAT_LOADED, filename.c_str()));
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user