fix: copy file with long long running ctx

This commit is contained in:
Urko. 2024-01-01 15:01:51 +01:00
parent 98bab81f3c
commit 1303d540cb
1 changed files with 5 additions and 1 deletions

View File

@ -34,9 +34,13 @@ func (b *BackBlaze) Sync(ctx context.Context) error {
b.logger.Infoln("bucket found:", bc.Name())
if b.options.FilePath != "" {
// Create a separate context for long-running operations
longRunningCtx, cancelLongRunningOps := context.WithCancel(context.Background())
defer cancelLongRunningOps()
b.logger.Infoln("file:", b.options.FilePath)
if err := b.copyFile(ctx, bc, b.options.FilePath); err != nil {
if err := b.copyFile(longRunningCtx, bc, b.options.FilePath); err != nil {
return fmt.Errorf("copyFile %w", err)
}
return nil