feat(content_hash): propagate etag and hash_content to */resources
This commit is contained in:
@@ -21,6 +21,7 @@ use crate::application::ports::file_ports::FileRetrievalUseCase;
|
||||
use crate::application::ports::folder_ports::FolderUseCase;
|
||||
use crate::application::ports::inbound::SearchUseCase;
|
||||
use crate::common::di::AppState;
|
||||
use crate::domain::entities::file::File;
|
||||
use crate::interfaces::errors::AppError;
|
||||
use crate::interfaces::middleware::auth::CurrentUser;
|
||||
use crate::interfaces::nextcloud::webdav_handler::{
|
||||
@@ -250,9 +251,16 @@ async fn handle_search(
|
||||
|
||||
/// Build a `FileDto` from a search file result.
|
||||
fn file_dto_from_search(fr: &crate::application::dtos::search_dto::SearchFileResultDto) -> FileDto {
|
||||
// `SearchFileResultDto` doesn't carry `blob_hash`; the SEARCH /
|
||||
// REPORT XML emitter doesn't read `content_hash` or `etag` off
|
||||
// these DTOs anyway, so leaving them empty here is correct.
|
||||
// Route ETag through `File::compute_etag` so REPORT/SEARCH hits
|
||||
// emit the same opaque token NC's sync client cached from the
|
||||
// earlier PROPFIND walk — without this, NC's conditional-request
|
||||
// logic on search results disagrees with its own cached state
|
||||
// and triggers a spurious re-fetch.
|
||||
let etag = if fr.blob_hash.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
File::compute_etag(&fr.blob_hash, fr.modified_at)
|
||||
};
|
||||
FileDto {
|
||||
id: fr.id.clone(),
|
||||
name: fr.name.clone(),
|
||||
@@ -270,8 +278,8 @@ fn file_dto_from_search(fr: &crate::application::dtos::search_dto::SearchFileRes
|
||||
size_formatted: format_file_size(fr.size),
|
||||
owner_id: None,
|
||||
sort_date: None,
|
||||
content_hash: String::new(),
|
||||
etag: String::new(),
|
||||
content_hash: fr.blob_hash.clone(),
|
||||
etag,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user