use crate::cleaners::{Cleaner, ScanContext, item_from_path};
use crate::model::{CleanerGroup, Plan};
use anyhow::Result;
pub struct ThumbnailsCleaner;
impl ThumbnailsCleaner {
pub fn new() -> Self {
Self
}
}
impl Cleaner for ThumbnailsCleaner {
fn id(&self) -> &'static str {
"thumbnails"
}
fn description(&self) -> &'static str {
"Thumbnail cache under XDG cache"
}
fn group(&self) -> CleanerGroup {
CleanerGroup::Cache
}
fn scan(&self, ctx: &ScanContext) -> Result<Plan> {
let path = ctx.base_dirs.cache_dir().join("thumbnails");
let mut items = Vec::new();
if let Some(item) = item_from_path(
&path,
self.id(),
self.group(),
Some("Thumbnail cache"),
&ctx.filter,
)? {
items.push(item);
}
Ok(Plan::new(items))
}
}