Skip to content

Commit

Permalink
do not flag as deleted if failed
Browse files Browse the repository at this point in the history
  • Loading branch information
gioelecerati committed Apr 29, 2024
1 parent 7f6fb82 commit 60afca3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions task/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,15 @@ func deleteAsset(asset *api.Asset, r *runner, ctx context.Context) error {
return err

Check warning on line 610 in task/runner.go

View check run for this annotation

Codecov / codecov/patch

task/runner.go#L606-L610

Added lines #L606 - L610 were not covered by tests
}

isErr := false

Check warning on line 613 in task/runner.go

View check run for this annotation

Codecov / codecov/patch

task/runner.go#L613

Added line #L613 was not covered by tests

for pi != nil {
for _, file := range pi.Files() {
glog.Infof("Found file %v", file.Name)
err := assetOS.DeleteFile(ctx, file.Name)
if err != nil {
glog.Errorf("Error deleting file %v: %v", file.Name, err)
isErr = true
continue

Check warning on line 622 in task/runner.go

View check run for this annotation

Codecov / codecov/patch

task/runner.go#L615-L622

Added lines #L615 - L622 were not covered by tests
}
glog.Infof("Deleted file %v", file.Name)
Expand All @@ -626,6 +629,7 @@ func deleteAsset(asset *api.Asset, r *runner, ctx context.Context) error {
pi, err = pi.NextPage()
if err != nil {
glog.Errorf("Failed to load next page of files for asset %v: %v", asset.ID, err)
isErr = true
break

Check warning on line 633 in task/runner.go

View check run for this annotation

Codecov / codecov/patch

task/runner.go#L628-L633

Added lines #L628 - L633 were not covered by tests
}
} else {
Expand All @@ -650,6 +654,10 @@ func deleteAsset(asset *api.Asset, r *runner, ctx context.Context) error {
glog.Infof("Unpinned asset=%v from IPFS", asset.ID)

Check warning on line 654 in task/runner.go

View check run for this annotation

Codecov / codecov/patch

task/runner.go#L654

Added line #L654 was not covered by tests
}

if isErr {
return errors.New("error deleting files")

Check warning on line 658 in task/runner.go

View check run for this annotation

Codecov / codecov/patch

task/runner.go#L657-L658

Added lines #L657 - L658 were not covered by tests
}

err = r.lapi.FlagAssetAsDeleted(asset.ID)
if err != nil {
glog.Errorf("Error flagging asset as deleted: %v", err)
Expand Down

0 comments on commit 60afca3

Please sign in to comment.