SwiftcordApp / Swiftcord

A fully native Discord client for macOS built 100% in Swift!
https://swiftcordapp.github.io/Swiftcord/
GNU General Public License v3.0
1.85k stars 84 forks source link

[Enhancement]: Clean cache feature in Settings #146

Open Jerry23011 opened 1 year ago

Jerry23011 commented 1 year ago

Describe Your Request

Swiftcord generates cache at ~/Library/Containers/io.cryptoalgo.swiftcord. Perhaps a button in Settings to clean it would be great.

Category

Settings

Other Category

No response

Screenshots

截屏2023-05-11 12 38 44
cryptoAlgorithm commented 1 year ago

Deleting the whole sandbox container folder (at ~/Library/Containers/io.cryptoalgo.swiftcord) might lead to unexpected consequences (since it stores quite a bit more than caches lol). The bulk of the storage is used by ~/Library/Containers/io.cryptoalgo.swiftcord/Data/Library/Caches, which is probably safe to delete, but I'm not sure if it would lead to inconsistent behaviour if the whole folder is simply deleted. Also, macOS automatically purges these cache folders in a safe fashion when low on storage (another benefit of being a native app), so there is little benefit to deleting them proactively.

The caches mostly store image data (e.g. profile images and server icons), and is limited to 100MB 256MB (so the oldest images will be deleted when the limit is hit), so it is fairly beneficial to simply keep the cache around.

cryptoAlgorithm commented 1 year ago

Also, the cache is crucial to smooth message history scrolling. Without it, reloading every profile image and media every time they scroll into view causes poor performance. And as such, you'll notice that the cache folder quickly grows (capped at 100MB 256MB) after being cleared, especially if many messages are loaded.

cryptoAlgorithm commented 1 year ago

However since there is interest for such an option (and it doesn't seem too hard to implement), I'll probably implement a "clear image cache" button.

Jerry23011 commented 1 year ago

So there is a limit, I didn't know 😂 I'm just afraid that it'll eventually pile up to several gigabytes, lol