fix(fetch): fix sizeconvert on raw number

This commit is contained in:
zawz 2022-04-11 10:24:28 +02:00
parent e2067774cc
commit 9d7321fce5

View file

@ -21,8 +21,13 @@ uint64_t sizeconvert(std::string const& in)
{ {
if(in.size()==0) if(in.size()==0)
return 0; return 0;
double num=std::stod(in.substr(0, in.size()-1)); double num=0;
switch(in[in.size()-1]) char c=0;
c = in[in.size()-1];
if(!(c >= '0' && c <= '9')) {
num=std::stod(in.substr(0, in.size()-1));
}
switch(c)
{ {
case 'K': return (uint64_t) (num * KB_MULT); break; case 'K': return (uint64_t) (num * KB_MULT); break;
case 'M': return (uint64_t) (num * MB_MULT); break; case 'M': return (uint64_t) (num * MB_MULT); break;