diff --git a/endpoints/drive/webdav/file.go b/endpoints/drive/webdav/file.go index bae07af1..ab1ee410 100644 --- a/endpoints/drive/webdav/file.go +++ b/endpoints/drive/webdav/file.go @@ -9,6 +9,7 @@ import ( "crypto/sha512" "encoding/xml" "fmt" + "github.com/sirupsen/logrus" "io" "io/fs" "net/http" @@ -121,7 +122,9 @@ func (f *webdavFile) checksum() (string, error) { if _, err := io.Copy(hash, file); err != nil { return "", err } - return fmt.Sprintf("%x", hash.Sum(nil)), nil + sha512 := fmt.Sprintf("%x", hash.Sum(nil)) + logrus.Infof("%v = %v", f.name, sha512) + return sha512, nil } func (f *webdavFile) updateModtime(path string, modtime time.Time) error { diff --git a/util/sync/webdavClient/client.go b/util/sync/webdavClient/client.go index fd4d4d51..cb21a524 100644 --- a/util/sync/webdavClient/client.go +++ b/util/sync/webdavClient/client.go @@ -97,6 +97,7 @@ type props struct { ContentType string `xml:"DAV: prop>getcontenttype,omitempty"` ETag string `xml:"DAV: prop>getetag,omitempty"` Modified string `xml:"DAV: prop>getlastmodified,omitempty"` + Checksum string `xml:"zrok: prop>checksum,omitempty"` } type Response struct { @@ -159,7 +160,7 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) { } err := c.propfind(path, false, - ` + ` @@ -167,6 +168,8 @@ func (c *Client) ReadDir(path string) ([]os.FileInfo, error) { + + `, &Response{}, @@ -211,7 +214,7 @@ func (c *Client) Stat(path string) (os.FileInfo, error) { } err := c.propfind(path, true, - ` + ` @@ -219,6 +222,7 @@ func (c *Client) Stat(path string) (os.FileInfo, error) { + `, &Response{}, diff --git a/util/sync/webdavClient/file.go b/util/sync/webdavClient/file.go index 0925be67..ce1033ef 100644 --- a/util/sync/webdavClient/file.go +++ b/util/sync/webdavClient/file.go @@ -15,6 +15,7 @@ type File struct { modified time.Time etag string isdir bool + checksum string } // Path returns the full path of a file @@ -62,6 +63,10 @@ func (f File) IsDir() bool { return f.isdir } +func (f File) Checksum() string { + return f.checksum +} + // Sys ???? func (f File) Sys() interface{} { return nil