Fix deletion not deleting thumbnails of file

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 2 years ago
parent ef30e38246
commit 15e31fbf79

@ -95,6 +95,20 @@ impl ThumbnailStore {
fs::rename(src_dir, dst_dir).await
}
/// Deletes all thumbnails of a parent
#[tracing::instrument(level = "debug")]
pub async fn delete_parent<S: AsRef<str> + Debug>(&self, parent: S) -> Result<()> {
let path = PathBuf::from(parent.as_ref());
if !path.exists() {
tracing::warn!("directory {:?} doesn't exist", path);
return Ok(());
}
fs::remove_dir_all(&path).await?;
Ok(())
}
/// Returns the size of the folder
#[tracing::instrument(level = "debug")]
pub async fn get_size(&self) -> RepoResult<u64> {

@ -148,8 +148,10 @@ impl Repo {
#[tracing::instrument(level = "debug", skip(self, file))]
pub async fn delete_file(&self, file: File) -> RepoResult<()> {
let cd = file.cd().to_owned();
let cd_string = file.encoded_cd();
file.delete().await?;
self.main_storage.delete_file(&cd).await?;
self.thumbnail_storage.delete_parent(&cd_string).await?;
Ok(())
}

Loading…
Cancel
Save