-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ 支持计算缓存目录大小和清理超期缓存 #82
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在Tauri中,除了提供command功能,还提供了Event 来推送消息,也许这边的实现中的缓存统计、清理缓存过程、清理完成等可以通过event来由Rust 部分主动推送?
此外,也许也能通过一个独立的携程来专门处理cache清理的相关任务,利用消息队列来推送清理相关请求,可以避免使用互斥锁。这样command部分只需要推送cache任务即可
for entry in fs::read_dir(cache_dir)? { | ||
let entry = entry?; | ||
let metadata = entry.metadata()?; | ||
let modified = metadata.modified().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里应该使用的是AccessTime 吧?将近3个月没有访问的文件夹删除?
for entry in fs::read_dir(cache_dir)? { | ||
let entry = entry?; | ||
let metadata = entry.metadata()?; | ||
let modified = metadata.modified().unwrap(); | ||
|
||
if now.duration_since(modified).unwrap() > Duration::from_secs(60 * 60 * 24 * 3) { | ||
debug!("remove dir: {:?}", entry.path()); | ||
fs::remove_dir_all(entry.path())?; | ||
count += 1; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里只遍历一层会不会容易删除不完整?增加一层便利深度也许更好?
<v-btn v-else v-bind="props" :color="color" :loading="cacheClearManager.status.status === 'Clearing'" :aria-disabled="cacheClearManager.status.status === 'Clearing'" | ||
@click="cacheClearManager.clearCacheDir"> | ||
立即清理 | ||
<v-tooltip activator="parent" location="top">超过 3 天的缓存将被清除</v-tooltip> | ||
</v-btn> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这边需要搞个清理中的进度条吗?
https://vuetifyjs.com/en/components/progress-circular/
这得引入tokio依赖了吧 |
tokio 不是 tauri 本来就在依赖里面吗? |
感觉需要实现两个要求
|
那也许Event更好? 这样就能保证同时只有一个清理在运行 |
在设置页面
顺便修改了初始窗口大小到 1280x720