serve webdav,http: fix directory Last-Modified using --default-time fallback - fixes #9905 - #9906
Open
sk-sanjay01 wants to merge 1 commit into
Open
Conversation
Member
|
Testing equality against the default time is a bit untidy. The What do you think of that? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change do?
Backends without real directory metadata (Swift, S3-style buckets, memory)
list directories as synthesized pseudo-entries with an unknown modtime.
fs.Dir.ModTime()falls back to the configured--default-time(default2000-01-01) whenever the real modtime is unknown, and this frozen sentinel
was being passed straight through as the
Last-Modifiedheader inserve httpdirectory listings, and as the PROPFINDgetlastmodified/OwnCloud
lastmodifiedproperties inserve webdav. Because the valuenever changes, reverse proxies and WebDAV clients that use
Last-Modifiedfor cache validation see the same date forever and can keep serving stale
directory listings indefinitely.
This makes both servers substitute the current time for the
--default-timesentinel, but only when the entry being served is adirectory — files, and any directory with a real known modtime, are
unaffected.
Repro, verified with and without the fix (using the
:memory:backend,which synthesizes zero-modtime directories the same way Swift/S3 do):
Testing done:
go build ./...,go vet ./...,golangci-lint run ./cmd/serve/http/... ./cmd/serve/webdav/...(0 issues)go test ./cmd/serve/http/...andgo test ./cmd/serve/webdav/..., including two new tests using the:memory:backend to reproduce a zero-modtime directory without needing Swift credentials:TestDirectoryListingLastModifiedUnknownModTime(serve http) andTestPROPFINDLastModifiedUnknownModTime(serve webdav, PROPFIND). Both verified to fail on unpatched code and pass with the fix.rclone serve http :memory:andrclone serve webdav :memory:, uploaded a file into a subdirectory, and confirmed the directory'sLast-Modified/getlastmodifiedvalue before and after the fix as shown above.Linked issue
Fixes #9905
Checklist
test_allpasses for this backend... (not applicable — not a backend change)