saoudrizwan / Disk

Easily persist structs, images, and data on iOS
MIT License
3.1k stars 170 forks source link

Cannot clear .cache on device #24

Closed bassebaba closed 6 years ago

bassebaba commented 6 years ago

try Disk.clear(.caches) Works in the simulator, but on my device all I get is an error: "Snapshots" couldn't be removed because you don't have permission to access it.

Save/retrieve works on the device.

iOS 11.1.2 (15B202)

What am I doing wrong? Do I need to ask for some sort of permissions?

Edit: Did a bit of further digging: https://stackoverflow.com/questions/12488462/ios-directory-structure-whats-snapshots-file

The Snapshots file/folder exists both in the simulator and on the actual device (phone). The difference is that on the simulator it gets deleted, on the phone I get the error message...

saoudrizwan commented 6 years ago

Hey @bassebaba thanks for bringing this to my attention! I fixed this bug in the latest release v0.3.3: https://github.com/saoudrizwan/Disk/commit/246065582c25a0e9bb13b1d46b5a0c9f32703ece

These special non-removable subdirectories (like "Snapshots") get skipped over now.

Update your pod to this new version and try running your code again.

bassebaba commented 6 years ago

Works perfect now, thanks for the fast fix!