diff --git a/mediarepo-api/Cargo.toml b/mediarepo-api/Cargo.toml index 32ecb6f..a49d486 100644 --- a/mediarepo-api/Cargo.toml +++ b/mediarepo-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mediarepo-api" -version = "0.11.0" +version = "0.11.1" edition = "2018" license = "gpl-3" diff --git a/mediarepo-api/src/client_api/file.rs b/mediarepo-api/src/client_api/file.rs index 8940ba7..624ffe9 100644 --- a/mediarepo-api/src/client_api/file.rs +++ b/mediarepo-api/src/client_api/file.rs @@ -146,4 +146,12 @@ where self.emit_and_get("add_file", payload).await } + + /// Deletes all thumbnails of a file to regenerate them when requested + #[tracing::instrument(level = "debug", skip(self))] + pub async fn delete_thumbnails(&self, file_id: FileIdentifier) -> ApiResult<()> { + self.emit("delete_thumbnails", file_id).await?; + + Ok(()) + } } diff --git a/mediarepo-api/src/tauri_plugin/commands/file.rs b/mediarepo-api/src/tauri_plugin/commands/file.rs index 6d68922..543efec 100644 --- a/mediarepo-api/src/tauri_plugin/commands/file.rs +++ b/mediarepo-api/src/tauri_plugin/commands/file.rs @@ -113,6 +113,14 @@ pub async fn save_file_locally( Ok(()) } +#[tauri::command] +pub async fn delete_thumbnail(api_state: ApiAccess<'_>, id: i64) -> PluginResult<()> { + let api = api_state.api().await?; + api.file.delete_thumbnails(FileIdentifier::ID(id)).await?; + + Ok(()) +} + #[tauri::command] pub async fn resolve_paths_to_files(paths: Vec) -> PluginResult> { let mut files = Vec::new(); diff --git a/mediarepo-api/src/tauri_plugin/mod.rs b/mediarepo-api/src/tauri_plugin/mod.rs index 55d62e8..b63f7a4 100644 --- a/mediarepo-api/src/tauri_plugin/mod.rs +++ b/mediarepo-api/src/tauri_plugin/mod.rs @@ -53,7 +53,8 @@ impl MediarepoPlugin { update_file_name, resolve_paths_to_files, add_local_file, - save_file_locally + save_file_locally, + delete_thumbnail ]), } }