From 4fc9583feb5c1dd44c9bb4657e91460ebc9f08de Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Sat, 15 Feb 2025 19:26:09 -0500 Subject: [PATCH] dropbox: Retry link without expiry Dropbox only allows public links with expiry for certain account types. Rather than erroring for other accounts, retry without expiry. --- backend/dropbox/dropbox.go | 10 ++++++++++ fstest/test_all/config.yaml | 4 ---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.go index b02ff6f4b..661bc8241 100644 --- a/backend/dropbox/dropbox.go +++ b/backend/dropbox/dropbox.go @@ -1333,6 +1333,16 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration, return shouldRetry(ctx, err) }) + if err != nil && createArg.Settings.Expires != nil && strings.Contains(err.Error(), sharing.SharedLinkSettingsErrorNotAuthorized) { + // Some plans can't create links with expiry + fs.Debugf(absPath, "can't create link with expiry, trying without") + createArg.Settings.Expires = nil + err = f.pacer.Call(func() (bool, error) { + linkRes, err = f.sharing.CreateSharedLinkWithSettings(&createArg) + return shouldRetry(ctx, err) + }) + } + if err != nil && strings.Contains(err.Error(), sharing.CreateSharedLinkWithSettingsErrorSharedLinkAlreadyExists) { fs.Debugf(absPath, "has a public link already, attempting to retrieve it") diff --git a/fstest/test_all/config.yaml b/fstest/test_all/config.yaml index 6c5c85c31..b108dccfe 100644 --- a/fstest/test_all/config.yaml +++ b/fstest/test_all/config.yaml @@ -144,10 +144,6 @@ backends: - backend: "dropbox" remote: "TestDropbox:" fastlist: false - ignore: - # This test doesn't work on a standard dropbox account because it - # tries to set the expiry of the link - - TestIntegration/FsMkdir/FsPutFiles/PublicLink # - backend: "filefabric" # remote: "TestFileFabric:" # fastlist: false