Skip to content

Commit

Permalink
FMWK-399-remove-artifacts-flag
Browse files Browse the repository at this point in the history
- ShouldClearTarget()
  • Loading branch information
filkeith committed Sep 19, 2024
1 parent f18f8c4 commit b5c3cb9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/internal/app/writers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func newLocalWriter(ctx context.Context, b *models.Backup, c *models.Common) (ba
opts = append(opts, local.WithFile(b.OutputFile))
}

if b.RemoveFiles || b.RemoveArtifacts {
if b.ShouldClearTarget() {
opts = append(opts, local.WithRemoveFiles())
}

Expand Down Expand Up @@ -72,7 +72,7 @@ func newS3Writer(
opts = append(opts, s3.WithFile(path))
}

if b.RemoveFiles || b.RemoveArtifacts {
if b.ShouldClearTarget() {
opts = append(opts, s3.WithRemoveFiles())
}

Expand Down Expand Up @@ -102,7 +102,7 @@ func newGcpWriter(
opts = append(opts, storage.WithFile(b.OutputFile))
}

if b.RemoveFiles || b.RemoveArtifacts {
if b.ShouldClearTarget() {
opts = append(opts, storage.WithRemoveFiles())
}

Expand Down Expand Up @@ -132,7 +132,7 @@ func newAzureWriter(
opts = append(opts, blob.WithFile(b.OutputFile))
}

if b.RemoveFiles || b.RemoveArtifacts {
if b.ShouldClearTarget() {
opts = append(opts, blob.WithRemoveFiles())
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/internal/models/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ type Backup struct {
ParallelNodes bool
RemoveArtifacts bool
}

// ShouldClearTarget check if we should clean target directory.
func (b *Backup) ShouldClearTarget() bool {
return b.RemoveFiles || b.RemoveArtifacts
}

0 comments on commit b5c3cb9

Please sign in to comment.