From 10854d0ce38843428d1cd70aecd6f497811d0829 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Thu, 4 Dec 2025 18:50:51 -0600 Subject: [PATCH] webdav: dav2fs-fix --- config.ru | 8 ++++++-- models/site.rb | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config.ru b/config.ru index 2bb8742e..6847d88f 100644 --- a/config.ru +++ b/config.ru @@ -46,7 +46,7 @@ map '/webdav' do case request_method when 'OPTIONS' - return [200, {'Allow' => 'OPTIONS, GET, HEAD, PUT, DELETE, PROPFIND, MKCOL, MOVE', 'DAV' => '1,2'}, ['']] + return [200, {'Allow' => 'OPTIONS, GET, HEAD, PUT, DELETE, PROPFIND, MKCOL, MOVE', 'DAV' => '1'}, ['']] when 'GET', 'HEAD' begin @@ -86,6 +86,10 @@ map '/webdav' do 'Last-Modified' => last_modified.httpdate } + if site_file&.sha1_hash + headers['ETag'] = %("#{site_file.sha1_hash}") + end + if request_method == 'HEAD' return [200, headers, []] end @@ -205,7 +209,7 @@ map '/webdav' do XML - return [207, {'Content-Type' => 'application/xml; charset=utf-8', 'DAV' => '1,2'}, [xml]] + return [207, {'Content-Type' => 'application/xml; charset=utf-8', 'DAV' => '1'}, [xml]] when 'PUT' tmpfile = Tempfile.new('davfile', encoding: 'binary') diff --git a/models/site.rb b/models/site.rb index 3b464460..0071b000 100644 --- a/models/site.rb +++ b/models/site.rb @@ -1306,6 +1306,7 @@ class Site < Sequel::Model file[:size] = site_file.size unless file[:is_directory] file[:created_at] = site_file.created_at file[:updated_at] = site_file.updated_at ? site_file.updated_at : site_file.created_at + file[:sha1_hash] = site_file.sha1_hash end file[:is_html] = !(extname.match(HTML_REGEX)).nil?