alist/server/webdav/util.go
Sean a3748af772
feat: misc improvements about upload/copy/hash (#5045)
general: add createTime/updateTime support in webdav and some drivers
general: add hash support in some drivers
general: cross-storage rapid-upload support
general: enhance upload to avoid local temp file if possible
general: replace readseekcloser with File interface to speed upstream operations
feat(aliyun_open): same as above
feat(crypt): add hack for 139cloud

Close #4934 
Close #4819 

baidu_netdisk needs to improve the upload code to support rapid-upload
2023-08-27 21:14:23 +08:00

30 lines
735 B
Go

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()
}