parent
0126af4de0
commit
28b61a93fd
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
`<D:locktype><D:write/></D:locktype>` +
|
||||
`</D:lockentry>`, 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("<checksum>%s:%s</checksum>", hashType.Name, hashValue)
|
||||
}
|
||||
return checksums, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user