From c304b4f52b1e7c90ab1ca965b6893fc22c7f47a7 Mon Sep 17 00:00:00 2001 From: MaxJa4 <74194322+MaxJa4@users.noreply.github.com> Date: Wed, 23 Aug 2023 19:10:33 +0200 Subject: [PATCH] Addressing comments part 1 --- internal/storage/dropbox/dropbox.go | 7 +++---- test/dropbox/openapi-mock.yaml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/storage/dropbox/dropbox.go b/internal/storage/dropbox/dropbox.go index 8a9c23c..f81637c 100644 --- a/internal/storage/dropbox/dropbox.go +++ b/internal/storage/dropbox/dropbox.go @@ -52,7 +52,7 @@ func NewStorageBackend(opts Config, logFunc storage.Log) (storage.Backend, error logFunc(storage.LogLevelInfo, "Dropbox", "Fetching fresh access token for Dropbox storage backend.") token := &oauth2.Token{RefreshToken: opts.RefreshToken} if !isCITest { - tkSource := conf.TokenSource(context.TODO(), &oauth2.Token{RefreshToken: opts.RefreshToken}) + tkSource := conf.TokenSource(context.Background(), &oauth2.Token{RefreshToken: opts.RefreshToken}) var err error token, err = tkSource.Token() if err != nil { @@ -101,11 +101,10 @@ func (b *dropboxStorage) Copy(file string) error { if _, err := b.client.CreateFolderV2(folderArg); err != nil { switch err := err.(type) { case files.CreateFolderV2APIError: - if err.EndpointError.Path.Tag == files.WriteErrorConflict { - b.Log(storage.LogLevelInfo, b.Name(), "Destination path '%s' already exists in Dropbox, no new directory required.", b.DestinationPath) - } else { + if err.EndpointError.Path.Tag != files.WriteErrorConflict { return fmt.Errorf("(*dropboxStorage).Copy: Error creating directory '%s' in Dropbox: %w", b.DestinationPath, err) } + b.Log(storage.LogLevelInfo, b.Name(), "Destination path '%s' already exists in Dropbox, no new directory required.", b.DestinationPath) default: return fmt.Errorf("(*dropboxStorage).Copy: Error creating directory '%s' in Dropbox: %w", b.DestinationPath, err) } diff --git a/test/dropbox/openapi-mock.yaml b/test/dropbox/openapi-mock.yaml index 34366f9..21707b6 100644 --- a/test/dropbox/openapi-mock.yaml +++ b/test/dropbox/openapi-mock.yaml @@ -22,4 +22,4 @@ generation: default_max_int: 2147483647 null_probability: 0 suppress_errors: false - use_examples: 'if_present' \ No newline at end of file + use_examples: 'if_present'