fix(webdav): make sure Mtime after Ctime (#6372 close #6371)

* fix(server/webdav) make sure Mtime >= Ctime

* fix(server/webdav) avoid variable 'stream' collides with imported package name
This commit is contained in:
potoo
2024-04-24 17:13:30 +08:00
committed by GitHub
parent 32ddab9b01
commit 479fc6d466
2 changed files with 14 additions and 9 deletions

View File

@ -8,16 +8,21 @@ import (
)
func (h *Handler) getModTime(r *http.Request) time.Time {
return h.getHeaderTime(r, "X-OC-Mtime")
return h.getHeaderTime(r, "X-OC-Mtime", "")
}
// owncloud/ nextcloud haven't impl this, but we can add the support since rclone may support this soon
// owncloud/ nextcloud haven't impl this, but we can add the support since rclone may support this soon.
// try ModTime if CreateTime not found in header
func (h *Handler) getCreateTime(r *http.Request) time.Time {
return h.getHeaderTime(r, "X-OC-Ctime")
return h.getHeaderTime(r, "X-OC-Ctime", "X-OC-Mtime")
}
func (h *Handler) getHeaderTime(r *http.Request, header string) time.Time {
func (h *Handler) getHeaderTime(r *http.Request, header, alternative string) time.Time {
hVal := r.Header.Get(header)
// try alternative
if hVal == "" && alternative != "" {
hVal = r.Header.Get(alternative)
}
if hVal != "" {
modTimeUnix, err := strconv.ParseInt(hVal, 10, 64)
if err == nil {