删除消息时,一并删除不再被引用的图片缓存 - #368
Open
Fiiiga wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
目前所有删除路径都只删了数据库记录,图片文件无法被清理,也不会自动过期。
导致即使用户清空全部历史记录,图片占用的空间也不会释放,只能重装解决。
改动
新增 MessageImageCleaner,删除消息时一并清理不再被引用的图片缓存。
因同一个图片地址可能被多条消息引用,所以做了引用检查。清理跑在后台队列上。
接入了 6 个删除点:列表左滑单条、左滑分组、分组清空按钮、actionSheet 删除、右上角垃圾桶批量删除,以及 delete=1 远程删除和 ttl 过期自动删除。
需要确认的取舍
下拉查看大图会重新联网下载。NotificationContentExtension 读的是同一份缓存,缓存删掉后会重新下载。(通知中心里推送的缩略图是 NSE 复制的附件副本,不受影响)。不确定是否符合预期。
后两个删除点(远程删除、ttl 过期)是否该包含在内?它们不是用户主动点删除,但同样是消息永久消失。如果觉得不合适可以拆掉。
没有加测试。
说明
代码跑了 CI 验证,但时间仓促未本地编译。