modify common.js -> function theConverter.bytes

dsouvik215

Member
May 25, 2018
896
0
16
On my rutorrent installation a modified version of the plugin "diskspace" run, so that not the diskspace is shown in the bottom bar but the quota each user have. The quotas are softcoded, so that more space can be used.
All in all, the values for free space get negative and the common.js function "theConverter" converts only positive values.

here the actual code:

Code:
bytes: function(bt, p)
{
p = (p == null) ? 1 : p;
var a = new Array(theUILang.bytes, theUILang.KB, theUILang.MB, theUILang.GB, theUILang.TB, theUILang.PB);
var ndx = 0;
if(bt == 0)
ndx = 1;
else
{
if(bt < 1024)
{
bt /= 1024;
ndx = 1;
}
else
while(bt >= 1024)
{
bt /= 1024;
ndx++;
}
}
}
return(this.round(bt, p) + " " + a[ndx]);
},
and the modified version:

Code:
bytes: function(bt, p)
{
p = (p == null) ? 1 : p;
var a = new Array(theUILang.bytes, theUILang.KB, theUILang.MB, theUILang.GB, theUILang.TB, theUILang.PB);
var ndx = 0;
while(Math.abs(bt) >= 1024)
{
bt /= 1024;
ndx++;
}
}
}
return(this.round(bt, p) + " " + a[ndx]);
},
So my question is, affects these changes some other code?
Furthermore, in my opinion the two if statements are redundant, because the value is smaller than 1024, so nothing should be changed. But with the ordinary code all values are converter at least to KiB.

Thanks in advance.
 

jith45

Member
May 25, 2018
960
0
16
On my rutorrent installation a modified version of the plugin "diskspace" run, so that not the diskspace is shown in the bottom bar but the quota each user have. The quotas are softcoded, so that more space can be used.
IMHO, your plugin has an error in implementation. It must stop all downloads when soft limit is reached. Because when hard limit will be reached your rtorrent will crash.
So my question is, affects these changes some other code?
Of course. For example, on the UI speed will be shown in bytes/sec instead KB/sec etc.