Web-If 1.09-6 file size error


Well-Known Member
I have upgraded Web-If and now some programmes are reporting file sizes like so:
Programme X (-1234567890.00 Bytes)
The numbers vary but are all 9-10 significant figures and are negative.
It's not obvious the difference between the ones which are like this and the ones which are the old normal.
Whether they have been shrunk or cropped doesn't appear to make any difference to whether they appear like this or not.

They still play and shrink OK, but the estimated time of shrinking is just under 24 hours for each one.
Same here. The vast majority of my programmes are now like this. Anything less than 1GB seems to be OK, whilst some that are more than this are also OK, but not many.
It seems that the size field in [file stat] is broken in Jim 0.75
humax# jimsh
Welcome to Jim version 0.75
. file stat "Goldfinger_20140202_1541.ts" st
dev 2050 ino 1788931 mode 33188 nlink 1 uid 0 gid 0 size -1826570368 atime 1391368039 mtime 1391368241 ctime 1391368242 type file

I've switched to [file size] instead so it will be fixed in the next version of webif and I'll take it up with the Jim developers.

--- /mod/webif/html/browse/index.jim~
+++ /mod/webif/html/browse/index.jim
@@ -103,8 +103,7 @@
       set ext [string tolower [file extension $file]]
       if {$ext in $::ignore || $ext ni $::include} { return }

-      file stat $file st
-      set rsz $st(size)
+      set rsz [file size $file]
       set sz [pretty_size $rsz]

       set base [file rootname $file]
Programme X (-1234567890.00 Bytes)
I've long thought that this notation is a bit stupid. How can you have a fraction of a byte? This shows up usually on the logging e.g. rsvsync.log (209.00 bytes)

Can this be fixed to remove the fractional part when it is not kB or MB or GB?
Done (will be in next release)

--- /mod/webif/lib/pretty_size~
+++ /mod/webif/lib/pretty_size
@@ -7,7 +7,7 @@
             set size $($size / 1024.0)

-       set size [format "%.2f" $size]
+       set size [string trimright [format "%.2f" $size] "0."]

        return "$size [lindex $units $i]"
"(0.00 bytes)" gets reduced to "( bytes)"

Presumably 10.00 bytes would get reduced to 1 bytes as well?
I think you've just over thought this whole function. I've tweaked it thusly:
                set units {KiB MiB GiB TiB}

                if {$size < 1024} then {
                        return "$size bytes"
                } else {

                        set size $($size / 1024.0)
                        for {set i 0} {$size > 1023} {incr i} {
                                set size $($size / 1024.0)

                        set size [format "%.2f" $size]

                        return "$size [lindex $units $i]"