"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
webdav/sharepoint: renew cookies after 12hrs
Henning Surmeier22ac80e83a19
diff --git a/backend/webdav/odrvcookie/renew.go b/backend/webdav/odrvcookie/renew.gonew file mode 100644index 000000000..dc1b142fc--- /dev/null+++ b/backend/webdav/odrvcookie/renew.go@@ -0,0 +1,32 @@+package odrvcookie++import (+ "time"++ "github.com/ncw/rclone/lib/rest"+)++// CookieRenew holds information for the renew+type CookieRenew struct {+ srv *rest.Client+ timer *time.Ticker+ renewFn func()+}++// NewRenew returns and starts a CookieRenew+func NewRenew(interval time.Duration, renewFn func()) *CookieRenew {+ renew := CookieRenew{+ timer: time.NewTicker(interval),+ renewFn: renewFn,+ }+ go renew.Renew()+ return &renew+}++// Renew calls the renewFn for every tick+func (c *CookieRenew) Renew() {+ for {+ <-c.timer.C // wait for tick+ c.renewFn()+ }+}diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.goindex 187ddad23..9ba4839a3 100644--- a/backend/webdav/webdav.go+++ b/backend/webdav/webdav.go@@ -372,6 +372,17 @@ func (f *Fs) setQuirks(vendor string) error {if err != nil {return err}++ odrvcookie.NewRenew(12*time.Hour, func() {+ spCookies, err := spCk.Cookies()+ if err != nil {+ fs.Errorf("could not renew cookies: %s", err.Error())+ return+ }+ f.srv.SetCookie(&spCookies.FedAuth, &spCookies.RtFa)+ fs.Debugf(spCookies, "successfully renewed sharepoint cookies")+ })+f.srv.SetCookie(&spCookies.FedAuth, &spCookies.RtFa)// sharepoint, unlike the other vendors, only lists files if the depth header is set to 0