WebDAV: Upgrade github.com/emersion/go-webdav in go.mod and go.sum

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer 2024-01-29 08:28:37 +01:00
parent 020a55ee13
commit f4f86baa21
3 changed files with 19 additions and 15 deletions

2
go.mod
View file

@ -138,7 +138,7 @@ require (
)
require (
github.com/emersion/go-webdav v0.4.0
github.com/emersion/go-webdav v0.5.0
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
)

7
go.sum
View file

@ -736,9 +736,9 @@ github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+m
github.com/dustinkirkland/golang-petname v0.0.0-20231002161417-6a283f1aaaf2 h1:S6Dco8FtAhEI/qkg/00H6RdEGC+MCy5GPiQ+xweNRFE=
github.com/dustinkirkland/golang-petname v0.0.0-20231002161417-6a283f1aaaf2/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc=
github.com/emersion/go-ical v0.0.0-20220601085725-0864dccc089f/go.mod h1:2MKFUgfNMULRxqZkadG1Vh44we3y5gJAtTBlVsx1BKQ=
github.com/emersion/go-vcard v0.0.0-20191221110513-5f81fa0d3cc7/go.mod h1:HMJKR5wlh/ziNp+sHEDV2ltblO4JD2+IdDOWtGcQBTM=
github.com/emersion/go-webdav v0.4.0 h1:iIkgitJBUNu2c1vL0KqqRb5jDjs38bzM/H7WxewrIh4=
github.com/emersion/go-webdav v0.4.0/go.mod h1:lkPYZO/vsDNV9GPyVMBBsAUZzzxINL97bEVFykApo58=
github.com/emersion/go-vcard v0.0.0-20230815062825-8fda7d206ec9/go.mod h1:HMJKR5wlh/ziNp+sHEDV2ltblO4JD2+IdDOWtGcQBTM=
github.com/emersion/go-webdav v0.5.0 h1:Ak/BQLgAihJt/UxJbCsEXDPxS5Uw4nZzgIMOq3rkKjc=
github.com/emersion/go-webdav v0.5.0/go.mod h1:ycyIzTelG5pHln4t+Y32/zBvmrM7+mV7x+V+Gx4ZQno=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@ -1194,6 +1194,7 @@ github.com/sunfish-shogi/bufseekio v0.0.0-20210207115823-a4185644b365/go.mod h1:
github.com/sunfish-shogi/bufseekio v0.1.0 h1:zu38kFbv0KuuiwZQeuYeS02U9AM14j0pVA9xkHOCJ2A=
github.com/sunfish-shogi/bufseekio v0.1.0/go.mod h1:dEzdXgvImkQ3WLI+0KQpmEx8T/C/ma9KeS3AfmU899I=
github.com/teambition/rrule-go v1.7.2/go.mod h1:mBJ1Ht5uboJ6jexKdNUJg2NcwP8uUMNvStWXlJD3MvU=
github.com/teambition/rrule-go v1.8.2/go.mod h1:Ieq5AbrKGciP1V//Wq8ktsTXwSwJHDD5mD/wLBGl3p4=
github.com/tensorflow/tensorflow v1.15.2 h1:7/f/A664Tml/nRJg04+p3StcrsT53mkcvmxYHXI21Qo=
github.com/tensorflow/tensorflow v1.15.2/go.mod h1:itOSERT4trABok4UOoG+X4BoKds9F3rIsySdn+Lvu90=
github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=

View file

@ -1,6 +1,7 @@
package webdav
import (
"context"
"fmt"
"io"
"net/http"
@ -20,6 +21,7 @@ import (
// Client represents a webdav client.
type Client struct {
client *webdav.Client
ctx context.Context
endpoint *url.URL
timeout time.Duration
mkdir map[string]bool
@ -68,6 +70,7 @@ func NewClient(serverUrl, user, pass string, timeout Timeout) (*Client, error) {
// Create a new webdav.Client wrapper.
result := &Client{
client: client,
ctx: context.Background(),
endpoint: endpoint,
timeout: Durations[timeout],
mkdir: make(map[string]bool, 128),
@ -97,7 +100,7 @@ func (c *Client) withTimeout(timeout time.Duration) *webdav.Client {
// readDirWithTimeout returns the contents of the specified directory with a request time limit if timeout is not negative.
func (c *Client) readDirWithTimeout(dir string, recursive bool, timeout time.Duration) ([]webdav.FileInfo, error) {
dir = trimPath(dir)
return c.withTimeout(timeout).Readdir(dir, recursive)
return c.withTimeout(timeout).ReadDir(c.ctx, dir, recursive)
}
// readDirWithTimeout returns the contents of the specified directory without a request timeout.
@ -193,7 +196,7 @@ func (c *Client) Mkdir(dir string) error {
c.mkdir[dir] = true
err := c.client.Mkdir(dir)
err := c.client.Mkdir(c.ctx, dir)
if err == nil {
return nil
@ -229,7 +232,7 @@ func (c *Client) Upload(src, dest string) (err error) {
var writer io.WriteCloser
writer, err = c.client.Create(dest)
writer, err = c.client.Create(c.ctx, dest)
if err != nil {
log.Errorf("webdav: %s", clean.Error(err))
@ -277,7 +280,7 @@ func (c *Client) Download(src, dest string, force bool) (err error) {
var reader io.ReadCloser
// Start download.
reader, err = c.client.Open(src)
reader, err = c.client.Open(c.ctx, src)
// Error?
if err != nil {
@ -315,18 +318,18 @@ func (c *Client) DownloadDir(src, dest string, recursive, force bool) (errs []er
}
for _, file := range files {
dest := path.Join(dest, file.Abs)
fileName := path.Join(dest, file.Abs)
if _, err = os.Stat(dest); err == nil {
// File already exists.
msg := fmt.Errorf("webdav: %s already exists", clean.Log(dest))
// Check if file already exists.
if _, err = os.Stat(fileName); err == nil {
msg := fmt.Errorf("webdav: %s already exists", clean.Log(fileName))
log.Warn(msg)
errs = append(errs, msg)
continue
}
if err = c.Download(file.Abs, dest, force); err != nil {
// Failed to download file.
// Download file from remote server.
if err = c.Download(file.Abs, fileName, force); err != nil {
errs = append(errs, err)
log.Error(err)
continue
@ -339,5 +342,5 @@ func (c *Client) DownloadDir(src, dest string, recursive, force bool) (errs []er
// Delete deletes a single file or directory on a remote server.
func (c *Client) Delete(dir string) error {
dir = trimPath(dir)
return c.client.RemoveAll(dir)
return c.client.RemoveAll(c.ctx, dir)
}