diff --git a/pkg/utils/hash.go b/pkg/utils/hash.go
index fa06bcc2..a281dd4e 100644
--- a/pkg/utils/hash.go
+++ b/pkg/utils/hash.go
@@ -10,6 +10,7 @@ import (
"errors"
"hash"
"io"
+ "iter"
"github.com/alist-org/alist/v3/internal/errs"
log "github.com/sirupsen/logrus"
@@ -226,3 +227,13 @@ func (hi HashInfo) GetHash(ht *HashType) string {
func (hi HashInfo) Export() map[*HashType]string {
return hi.h
}
+
+func (hi HashInfo) All() iter.Seq2[*HashType, string] {
+ return func(yield func(*HashType, string) bool) {
+ for hashType, hashValue := range hi.h {
+ if !yield(hashType, hashValue) {
+ return
+ }
+ }
+ }
+}
diff --git a/server/webdav/prop.go b/server/webdav/prop.go
index 5e053af4..a81f31b0 100644
--- a/server/webdav/prop.go
+++ b/server/webdav/prop.go
@@ -9,6 +9,7 @@ import (
"context"
"encoding/xml"
"errors"
+ "fmt"
"mime"
"net/http"
"path"
@@ -101,7 +102,7 @@ type DeadPropsHolder interface {
Patch([]Proppatch) ([]Propstat, error)
}
-// liveProps contains all supported, protected DAV: properties.
+// liveProps contains all supported properties.
var liveProps = map[xml.Name]struct {
// findFn implements the propfind function of this property. If nil,
// it indicates a hidden property.
@@ -160,6 +161,10 @@ var liveProps = map[xml.Name]struct {
findFn: findSupportedLock,
dir: true,
},
+ {Space: "http://owncloud.org/ns", Local: "checksums"}: {
+ findFn: findChecksums,
+ dir: false,
+ },
}
// TODO(nigeltao) merge props and allprop?
@@ -483,3 +488,11 @@ func findSupportedLock(ctx context.Context, ls LockSystem, name string, fi model
`` +
``, nil
}
+
+func findChecksums(ctx context.Context, ls LockSystem, name string, fi model.Obj) (string, error) {
+ checksums := ""
+ for hashType, hashValue := range fi.GetHash().All() {
+ checksums += fmt.Sprintf("%s:%s", hashType.Name, hashValue)
+ }
+ return checksums, nil
+}