react-native-fetch-blob
react-native-fetch-blob copied to clipboard
RNFetchBlob.fs.stat does not return the correct directory size
Hi! Thanks for this great repo :)
I'm trying to get the size of a dir I'm saving images to (see https://github.com/kfiroo/react-native-cached-image) but the stat method seems to return the wrong size.
Not being an iOS dev I couldn't really create a valuable PR but this guy on SO seems to have the right direction http://stackoverflow.com/a/28660040/220483
* Obviously this would have to work on Android too, I just haven't got that far with my testing yet :)
@kfiroo , thanks for the information. I think you're right,fs.stat does not return correct folder size ATM.
Basically, we can do this by checking the files' size recursively but if we're going to do this in native it might take some time.
@wkh237 Hey, reading a bit about stat, it seems it is not meant to return the size of directory recursively, so maybe this is not really a bug.
I would suggest however, that we would provide a way to do it natively, instead of having to go back and forth on the RN bridge (i.e. get the dir content -> get file sizes -> get internal dirs content -> back to start)
Currently I'm doing something like that https://github.com/kfiroo/react-native-cached-image/blob/master/ImageCacheProvider.js#L313 but I feel it might get slower as the cache size grows.
How would you suggest we go about it?
@kfiroo Do you have did it? I have same issue. Please share your solution if you did it.