ggunti/react-native-amazing-cropper

Android - cache file size grows after use the component

rpslpereiragithub opened this issue · 5 comments

During the upgrade RN from 0.59.9 to 0.63.2 I also upgraded the amazing-cropper to the latest version.

Everything work as expected but now when I crop the picture, after use the component the cache size of my app, on android grows more than 1 MB.
This was not happening before.

On my application I take a picture, afterwards, I cropped it using your component, and at the end I delete both pictures (original photo, and cropped file) using the RNFS.unlink.
At the end on Android the cache size of my application always grows. Any idea?

On IOS everythig work as expected, no footprint.

Thanks in advance.
Rui

MystL commented

I observed the same situation as well, I did the necessary housekeeping by deleting both original and cropped file but the storage grows by 1MB.

Any insights?

MystL commented

After some research I noticed that after every crop, there are 2 files created on the temp Data directory (but we only have access to one of that files through the croppedImageUri. The only workaround for me was to do a complete cleanup of the temp Data directory after using this component.

On Tue, Dec 1, 2020 at 5:18 AM Melvin Lee @.***> wrote: I observed the same situation as well, I did the necessary housekeeping by deleting both original and cropped file but the storage grows by 1MB. Any insights? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#36 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ543OHTSIARCOD5AUG55G3SSR4A5ANCNFSM4RCTJQGQ .
-- Rui Pedro Pereira

I see, for your case the temp data directory can be freely clean without concerns of other files that are unrelated to this process I guess?

@rpslpereiragithub Yes, you are right. So always remains some garbage files. Starting v0.2.2, the onDone function returns also the garbageUris as second parameter, so you have the possibility to clear the garbage uris from cache (using RNFS.unlink for example). Of course, garbageUris should not be used for anything else. It is returned just to give the possibility to clear unused uris from cache (see README file).