kiwix / java-libkiwix

Libkiwix binding for Java & Kotlin
https://central.sonatype.com/artifact/org.kiwix/libkiwix
GNU General Public License v3.0
3 stars 4 forks source link

`Archive.getFilesize()` returning the wrong file size #41

Closed MohitMaliFtechiz closed 1 year ago

MohitMaliFtechiz commented 1 year ago

We are encountering an issue with the getFilesize() method in the Archive, as it is returning an incorrect file size. Let's consider an example: the file 100r-off-the-grid_en_2023-07.zim should be 145.6 MB (or 149106 KiB), but when we retrieve the file size using Archive.getFilesize(), it returns 152684582 KiB, which is equivalent to 152684.582 MB.

To confirm this problem, we have a test case in our code repository at https://github.com/kiwix/java-libkiwix/blob/2f951febf31e52886457f521d10db3c78eec1db4/lib/src/test/test.java#L63C52-L63C52

assertEquals(66937, archive.getFilesize()); // The file size is in KiB

However, the expected file size of 66.937 MB is incorrect. In reality, the file size is 65.4 KB, as shown in the image below:

Screenshot from 2023-07-14 19-03-15

kelson42 commented 1 year ago

This is not a bug IMO. @rgaudin you have explained thid many times, do we have a doc somewhere?

rgaudin commented 1 year ago

It's not bug. libkiwix, unlike libzim returns this in KiB while libzim uses bytes.

See https://github.com/kiwix/libkiwix/blob/8ca809f8d908fd0bdbdb1d33735a4eb52c4b5a99/src/tools/archiveTools.cpp#L108