perf(dav): stream NC PROPFIND in batches; Range + 304 on WebDAV GETs
Two DAV-surface fixes that replicate patterns the codebase already had: NC PROPFIND (folder case) previously loaded EVERY child via unbounded list_files/list_folders and serialized the entire multistatus into one Vec (~2 KB per entry — a 50k-file folder meant ~100 MB of buffer per request, repeated constantly by sync clients). It now mirrors the native WebDAV handler's streaming builder: children are fetched in pages of PROPFIND_BATCH_SIZE (500), each page's favorites and oc:fileids are resolved with two batch queries, and the XML is yielded chunk by chunk — memory stays O(batch) and the first byte flows immediately. The single-file PROPFIND keeps a small buffered variant; the multistatus opening tag is factored into a shared helper so the namespace set cannot diverge. WebDAV GET (native and NC) ignored the Range header and never compared the ETag it emitted, so mount-style clients (rclone, davfs2, Finder) re-transferred whole files on every seek, resume, or revalidation. New shared `interfaces::range_requests` helpers — same semantics as the REST download endpoint, which now reuses the 304 helper too — give both GETs If-None-Match → 304, Range → 206/416, and Accept-Ranges advertising. https://claude.ai/code/session_01Dp3oWon5GBMVn4j3QXZdgx
This commit is contained in:
@@ -20,6 +20,7 @@ use crate::application::ports::{file_ports::OptimizedFileContent, folder_ports::
|
||||
use crate::common::di::AppState;
|
||||
use crate::interfaces::errors::AppError;
|
||||
use crate::interfaces::middleware::auth::AuthUser;
|
||||
use crate::interfaces::range_requests::not_modified_response;
|
||||
use crate::{application::dtos::file_dto::FileDto, domain::services::authorization::Permission};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -600,16 +601,8 @@ impl FileHandler {
|
||||
let etag = format!("\"{}\"", file_dto.etag);
|
||||
|
||||
// ── ETag (304 Not Modified) ──────────────────────────────────
|
||||
if let Some(inm) = headers.get(header::IF_NONE_MATCH)
|
||||
&& let Ok(client_etag) = inm.to_str()
|
||||
&& (client_etag == etag || client_etag == "*")
|
||||
{
|
||||
return Response::builder()
|
||||
.status(StatusCode::NOT_MODIFIED)
|
||||
.header(header::ETAG, &etag)
|
||||
.body(Body::empty())
|
||||
.unwrap()
|
||||
.into_response();
|
||||
if let Some(resp) = not_modified_response(&headers, &etag) {
|
||||
return resp.into_response();
|
||||
}
|
||||
|
||||
// ── Range Requests ───────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user