diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 1f0afcdc4..5f54a1cc6 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -151,6 +151,7 @@ func (rwChoices) Choices() []fs.BitsChoicesInfo { {Bit: uint64(rwOff), Name: "off"}, {Bit: uint64(rwRead), Name: "read"}, {Bit: uint64(rwWrite), Name: "write"}, + {Bit: uint64(rwFailOK), Name: "failok"}, } } @@ -160,6 +161,7 @@ type rwChoice = fs.Bits[rwChoices] const ( rwRead rwChoice = 1 << iota rwWrite + rwFailOK rwOff rwChoice = 0 ) @@ -173,6 +175,9 @@ var rwExamples = fs.OptionExamples{{ }, { Value: rwWrite.String(), Help: "Write the value only", +}, { + Value: rwFailOK.String(), + Help: "If writing fails log errors only, don't fail the transfer", }, { Value: (rwRead | rwWrite).String(), Help: "Read and Write the value.", diff --git a/backend/drive/metadata.go b/backend/drive/metadata.go index a79dac3af..a0b8d41c9 100644 --- a/backend/drive/metadata.go +++ b/backend/drive/metadata.go @@ -262,7 +262,7 @@ func (f *Fs) setLabels(ctx context.Context, info *drive.File, labels []*drive.La return f.shouldRetry(ctx, err) }) if err != nil { - return fmt.Errorf("failed to set owner: %w", err) + return fmt.Errorf("failed to set labels: %w", err) } return nil } @@ -553,7 +553,12 @@ func (f *Fs) updateMetadata(ctx context.Context, updateInfo *drive.File, meta fs } // Can't set Owner on upload so need to set afterwards callbackFns = append(callbackFns, func(ctx context.Context, info *drive.File) error { - return f.setOwner(ctx, info, v) + err := f.setOwner(ctx, info, v) + if err != nil && f.opt.MetadataOwner.IsSet(rwFailOK) { + fs.Errorf(f, "Ignoring error as failok is set: %v", err) + return nil + } + return err }) case "permissions": if !f.opt.MetadataPermissions.IsSet(rwWrite) { @@ -566,7 +571,13 @@ func (f *Fs) updateMetadata(ctx context.Context, updateInfo *drive.File, meta fs } // Can't set Permissions on upload so need to set afterwards callbackFns = append(callbackFns, func(ctx context.Context, info *drive.File) error { - return f.setPermissions(ctx, info, perms) + err := f.setPermissions(ctx, info, perms) + if err != nil && f.opt.MetadataPermissions.IsSet(rwFailOK) { + // We've already logged the permissions errors individually here + fs.Debugf(f, "Ignoring error as failok is set: %v", err) + return nil + } + return err }) case "labels": if !f.opt.MetadataLabels.IsSet(rwWrite) { @@ -579,7 +590,12 @@ func (f *Fs) updateMetadata(ctx context.Context, updateInfo *drive.File, meta fs } // Can't set Labels on upload so need to set afterwards callbackFns = append(callbackFns, func(ctx context.Context, info *drive.File) error { - return f.setLabels(ctx, info, labels) + err := f.setLabels(ctx, info, labels) + if err != nil && f.opt.MetadataLabels.IsSet(rwFailOK) { + fs.Errorf(f, "Ignoring error as failok is set: %v", err) + return nil + } + return err }) case "folder-color-rgb": updateInfo.FolderColorRgb = v