bugfix/thumbnails on update
Bug 1 & 2 (webdav_handler.rs handle_put() update branch):
- After a successful file update via WebDAV PUT, if the content type is a supported image:
a. delete_thumbnails(file_id) — evicts the stale moka cache entry
b. Spawns a background task to read the new blob bytes and call generate_all_sizes_background_from_bytes
Bug 3 & 4 (dedup_service.rs):
- Added thumbnail_service: Option<Arc<ThumbnailService>> field with a with_thumbnail_service() builder
- In remove_legacy_reference(): calls delete_blob_thumbnails(hash) when ref_count hits 0
- In remove_manifest_reference(): calls delete_blob_thumbnails(file_hash) when manifest's last ref is dropped
- Wired in di.rs — the thumbnail service is created before dedup service so the ordering works cleanly
This commit is contained in:
@@ -163,6 +163,12 @@ async fn handle_assemble(
|
||||
)
|
||||
.await
|
||||
.map_err(|e| AppError::internal_error(format!("Failed to update file: {}", e)))?;
|
||||
|
||||
state
|
||||
.core
|
||||
.refresh_thumbnails_after_update(dto.id.clone(), dto.etag.clone(), &content_type)
|
||||
.await;
|
||||
|
||||
Some(dto.etag)
|
||||
} else {
|
||||
// For new files we still need to read the temp file since create_file takes &[u8].
|
||||
|
||||
@@ -566,6 +566,16 @@ async fn handle_put(
|
||||
}
|
||||
}
|
||||
|
||||
// Bug 1 & 2 fix: invalidate stale thumbnail and regenerate from new blob.
|
||||
state
|
||||
.core
|
||||
.refresh_thumbnails_after_update(
|
||||
updated.id.clone(),
|
||||
updated.etag.clone(),
|
||||
&content_type,
|
||||
)
|
||||
.await;
|
||||
|
||||
return Ok(Response::builder()
|
||||
.status(StatusCode::NO_CONTENT)
|
||||
.header(header::ETAG, format!("\"{}\"", updated.etag))
|
||||
|
||||
Reference in New Issue
Block a user