mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-28 11:18:24 -04:00
feat(ocis): bump gowebdav
Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
2
go.mod
2
go.mod
@@ -340,7 +340,7 @@ require (
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
||||
|
||||
replace github.com/studio-b12/gowebdav => github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6
|
||||
replace github.com/studio-b12/gowebdav => github.com/kobergj/gowebdav v0.0.0-20250102091030-aa65266db202
|
||||
|
||||
replace github.com/egirna/icap-client => github.com/fschade/icap-client v0.0.0-20240802074440-aade4a234387
|
||||
|
||||
|
||||
4
go.sum
4
go.sum
@@ -93,8 +93,6 @@ github.com/RoaringBitmap/roaring v1.9.3 h1:t4EbC5qQwnisr5PrP9nt0IRhRTb9gMUgQF4t4
|
||||
github.com/RoaringBitmap/roaring v1.9.3/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6 h1:ws0yvsikTQdmheKINP16tBzAHdttrHwbz/q3Fgl9X1Y=
|
||||
github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE=
|
||||
github.com/agnivade/levenshtein v1.2.0 h1:U9L4IOT0Y3i0TIlUIDJ7rVUziKi/zPbrJGaFrtYH3SY=
|
||||
github.com/agnivade/levenshtein v1.2.0/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
@@ -704,6 +702,8 @@ github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90
|
||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/kobergj/gowebdav v0.0.0-20250102091030-aa65266db202 h1:A1xJ2NKgiYFiaHiLl9B5yw/gUBACSs9crDykTS3GuQI=
|
||||
github.com/kobergj/gowebdav v0.0.0-20250102091030-aa65266db202/go.mod h1:bHA7t77X/QFExdeAnDzK6vKM34kEZAcE1OX4MfiwjkE=
|
||||
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90 h1:pfI8Z5yavO6fU6vDGlWhZ4BgDlvj8c6xB7J57HfTPwA=
|
||||
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY=
|
||||
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
|
||||
|
||||
44
vendor/github.com/studio-b12/gowebdav/client.go
generated
vendored
44
vendor/github.com/studio-b12/gowebdav/client.go
generated
vendored
@@ -3,6 +3,7 @@ package gowebdav
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -159,6 +160,10 @@ func (p *propstat) Modified() time.Time {
|
||||
return time.Unix(0, 0)
|
||||
}
|
||||
|
||||
func (p *propstat) Lock() string {
|
||||
return p.Props.GetString(xml.Name{Space: "DAV:", Local: "lockdiscovery"})
|
||||
}
|
||||
|
||||
func (p *propstat) StatusCode() int {
|
||||
parts := strings.Split(p.Status, " ")
|
||||
if len(parts) < 2 {
|
||||
@@ -380,6 +385,37 @@ func (c *Client) Copy(oldpath, newpath string, overwrite bool) error {
|
||||
return c.copymove("COPY", oldpath, newpath, overwrite)
|
||||
}
|
||||
|
||||
// GetLock gets a lock
|
||||
func (c *Client) GetLock(path string) (string, error) {
|
||||
fi, err := c.Stat(path)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
f, ok := fi.(File)
|
||||
if !ok {
|
||||
// This won't happen unless implementation is changed
|
||||
return "", errors.New("Stat did not return a File")
|
||||
}
|
||||
|
||||
return f.Lock(), nil
|
||||
}
|
||||
|
||||
// Lock locks a file
|
||||
func (c *Client) Lock(path string, token string) error {
|
||||
return c.lock(path, token, false)
|
||||
}
|
||||
|
||||
// RefreshLock refreshes a lock
|
||||
func (c *Client) RefreshLock(path string, token string) error {
|
||||
return c.lock(path, token, true)
|
||||
}
|
||||
|
||||
// Unlock unlocks a file
|
||||
func (c *Client) Unlock(path string, token string) error {
|
||||
return c.unlock(path, token)
|
||||
}
|
||||
|
||||
// Read reads the contents of a remote file
|
||||
func (c *Client) Read(path string) ([]byte, error) {
|
||||
var stream io.ReadCloser
|
||||
@@ -456,7 +492,7 @@ func (c *Client) ReadStreamRange(path string, offset, length int64) (io.ReadClos
|
||||
|
||||
// Write writes data to a given path
|
||||
func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error) {
|
||||
s, err := c.put(path, bytes.NewReader(data))
|
||||
s, err := c.put(path, bytes.NewReader(data), "")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -472,7 +508,7 @@ func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
s, err = c.put(path, bytes.NewReader(data))
|
||||
s, err = c.put(path, bytes.NewReader(data), "")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -485,14 +521,14 @@ func (c *Client) Write(path string, data []byte, _ os.FileMode) (err error) {
|
||||
}
|
||||
|
||||
// WriteStream writes a stream
|
||||
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode) (err error) {
|
||||
func (c *Client) WriteStream(path string, stream io.Reader, _ os.FileMode, locktoken string) (err error) {
|
||||
|
||||
err = c.createParentCollection(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s, err := c.put(path, stream)
|
||||
s, err := c.put(path, stream, locktoken)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
7
vendor/github.com/studio-b12/gowebdav/file.go
generated
vendored
7
vendor/github.com/studio-b12/gowebdav/file.go
generated
vendored
@@ -31,7 +31,7 @@ func newFile(path, name string, p *propstat) *File {
|
||||
}
|
||||
path = FixSlashes(path)
|
||||
|
||||
f.name = name
|
||||
f.name = filepath.Base(name)
|
||||
f.path = filepath.Clean(filepath.Join(path, f.name))
|
||||
f.modified = p.Modified()
|
||||
f.etag = p.ETag()
|
||||
@@ -98,6 +98,11 @@ func (f File) Sys() interface{} {
|
||||
return f.propstat.Props
|
||||
}
|
||||
|
||||
// Lock returns the files lock
|
||||
func (f File) Lock() string {
|
||||
return f.propstat.Lock()
|
||||
}
|
||||
|
||||
func (f File) StatusCode() int {
|
||||
return f.propstat.StatusCode()
|
||||
}
|
||||
|
||||
63
vendor/github.com/studio-b12/gowebdav/requests.go
generated
vendored
63
vendor/github.com/studio-b12/gowebdav/requests.go
generated
vendored
@@ -105,6 +105,63 @@ func (c *Client) propfind(path string, self bool, body string, resp interface{},
|
||||
return parseXML(rs.Body, resp, parse)
|
||||
}
|
||||
|
||||
func (c *Client) lock(path string, token string, refresh bool) error {
|
||||
var body io.Reader
|
||||
if !refresh {
|
||||
b := strings.Builder{}
|
||||
|
||||
// build the lockinfo xml
|
||||
b.WriteString("<D:lockinfo>")
|
||||
// always use an exclusive lock
|
||||
b.WriteString("<D:lockscope><D:exclusive/></D:lockscope>")
|
||||
// always use a write lock
|
||||
b.WriteString("<D:locktype><D:write/></D:locktype>")
|
||||
// add the lock token
|
||||
b.WriteString("<d:locktoken><d:href>")
|
||||
b.WriteString(token)
|
||||
b.WriteString("</d:href></d:locktoken>")
|
||||
// close the lockinfo xml
|
||||
b.WriteString("</D:lockinfo>")
|
||||
|
||||
body = strings.NewReader(b.String())
|
||||
}
|
||||
|
||||
rs, err := c.req("LOCK", path, body, func(rq *http.Request) {
|
||||
rq.Header.Add("Content-Type", "application/xml;charset=UTF-8")
|
||||
rq.Header.Add("Accept", "application/xml,text/xml")
|
||||
rq.Header.Add("Accept-Charset", "utf-8")
|
||||
rq.Header.Add("Accept-Encoding", "")
|
||||
if refresh {
|
||||
rq.Header.Add("If", "("+token+")")
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer rs.Body.Close()
|
||||
|
||||
if rs.StatusCode != 200 {
|
||||
return NewPathError("LOCK", path, rs.StatusCode)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) unlock(path string, token string) error {
|
||||
rs, err := c.req("UNLOCK", path, nil, func(rq *http.Request) {
|
||||
rq.Header.Add("Lock-Token", "<"+token+">")
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer rs.Body.Close()
|
||||
|
||||
if rs.StatusCode != http.StatusNoContent {
|
||||
return NewPathError("UNLOCK", path, rs.StatusCode)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) doCopyMove(
|
||||
method string,
|
||||
oldpath string,
|
||||
@@ -160,8 +217,10 @@ func (c *Client) copymove(method string, oldpath string, newpath string, overwri
|
||||
return NewPathError(method, oldpath, s)
|
||||
}
|
||||
|
||||
func (c *Client) put(path string, stream io.Reader) (status int, err error) {
|
||||
rs, err := c.req("PUT", path, stream, nil)
|
||||
func (c *Client) put(path string, stream io.Reader, locktoken string) (status int, err error) {
|
||||
rs, err := c.req("PUT", path, stream, func(rq *http.Request) {
|
||||
rq.Header.Add("Lock-Token", "<"+locktoken+">")
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@@ -1813,7 +1813,7 @@ github.com/stretchr/testify/assert
|
||||
github.com/stretchr/testify/assert/yaml
|
||||
github.com/stretchr/testify/mock
|
||||
github.com/stretchr/testify/require
|
||||
# github.com/studio-b12/gowebdav v0.9.0 => github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6
|
||||
# github.com/studio-b12/gowebdav v0.9.0 => github.com/kobergj/gowebdav v0.0.0-20250102091030-aa65266db202
|
||||
## explicit; go 1.17
|
||||
github.com/studio-b12/gowebdav
|
||||
# github.com/tchap/go-patricia/v2 v2.3.1
|
||||
@@ -2398,7 +2398,7 @@ sigs.k8s.io/yaml/goyaml.v2
|
||||
# stash.kopano.io/kgol/rndm v1.1.2
|
||||
## explicit; go 1.13
|
||||
stash.kopano.io/kgol/rndm
|
||||
# github.com/studio-b12/gowebdav => github.com/aduffeck/gowebdav v0.0.0-20231215102054-212d4a4374f6
|
||||
# github.com/studio-b12/gowebdav => github.com/kobergj/gowebdav v0.0.0-20250102091030-aa65266db202
|
||||
# github.com/egirna/icap-client => github.com/fschade/icap-client v0.0.0-20240802074440-aade4a234387
|
||||
# github.com/unrolled/secure => github.com/DeepDiver1975/secure v0.0.0-20240611112133-abc838fb797c
|
||||
# github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240807130109-f62bb67e8c90
|
||||
|
||||
Reference in New Issue
Block a user