Addressing comments part 1

This commit is contained in:
MaxJa4 2023-08-23 19:10:33 +02:00
parent 08ae3c73c8
commit c304b4f52b
2 changed files with 4 additions and 5 deletions

View File

@ -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.") logFunc(storage.LogLevelInfo, "Dropbox", "Fetching fresh access token for Dropbox storage backend.")
token := &oauth2.Token{RefreshToken: opts.RefreshToken} token := &oauth2.Token{RefreshToken: opts.RefreshToken}
if !isCITest { 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 var err error
token, err = tkSource.Token() token, err = tkSource.Token()
if err != nil { if err != nil {
@ -101,11 +101,10 @@ func (b *dropboxStorage) Copy(file string) error {
if _, err := b.client.CreateFolderV2(folderArg); err != nil { if _, err := b.client.CreateFolderV2(folderArg); err != nil {
switch err := err.(type) { switch err := err.(type) {
case files.CreateFolderV2APIError: case files.CreateFolderV2APIError:
if err.EndpointError.Path.Tag == files.WriteErrorConflict { 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 {
return fmt.Errorf("(*dropboxStorage).Copy: Error creating directory '%s' in Dropbox: %w", b.DestinationPath, err) 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: default:
return fmt.Errorf("(*dropboxStorage).Copy: Error creating directory '%s' in Dropbox: %w", b.DestinationPath, err) return fmt.Errorf("(*dropboxStorage).Copy: Error creating directory '%s' in Dropbox: %w", b.DestinationPath, err)
} }

View File

@ -22,4 +22,4 @@ generation:
default_max_int: 2147483647 default_max_int: 2147483647
null_probability: 0 null_probability: 0
suppress_errors: false suppress_errors: false
use_examples: 'if_present' use_examples: 'if_present'