File size: 735 Bytes
7107f0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package webdav

import (
	log "github.com/sirupsen/logrus"
	"net/http"
	"strconv"
	"time"
)

func (h *Handler) getModTime(r *http.Request) time.Time {
	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
func (h *Handler) getCreateTime(r *http.Request) time.Time {
	return h.getHeaderTime(r, "X-OC-Ctime")
}

func (h *Handler) getHeaderTime(r *http.Request, header string) time.Time {
	hVal := r.Header.Get(header)
	if hVal != "" {
		modTimeUnix, err := strconv.ParseInt(hVal, 10, 64)
		if err == nil {
			return time.Unix(modTimeUnix, 0)
		}
		log.Warnf("getModTime in Webdav, failed to parse %s, %s", header, err)
	}
	return time.Now()
}