diff --git a/internal/sfa/activities/create_sip.go b/internal/sfa/activities/create_sip.go index 352a8fcd2..3f02b6c8a 100644 --- a/internal/sfa/activities/create_sip.go +++ b/internal/sfa/activities/create_sip.go @@ -3,7 +3,11 @@ package activities import ( "context" "errors" + "fmt" + "os" "os/exec" + + "go.artefactual.dev/tools/temporal" ) const SipCreationName = "sip-creation" @@ -34,6 +38,10 @@ func (sc *SipCreationActivity) Execute(ctx context.Context, params *SipCreationP return nil, errors.New("Failed to repackage sip correctly: " + res.Out) } + if err = os.Remove(params.SipPath); err != nil { + return nil, temporal.NewNonRetryableError(fmt.Errorf("error removing SIP: %v", err)) + } + res.NewSipPath = params.SipPath + "_bag" return res, nil } diff --git a/internal/sfa/activities/extract_package.go b/internal/sfa/activities/extract_package.go index 67b91b286..3f5c94a35 100644 --- a/internal/sfa/activities/extract_package.go +++ b/internal/sfa/activities/extract_package.go @@ -64,5 +64,9 @@ func (a *ExtractPackage) Execute(ctx context.Context, params *ExtractPackagePara path = filepath.Join(tempDir, entries[0].Name()) } + if err = os.Remove(params.Path); err != nil { + return nil, temporal.NewNonRetryableError(fmt.Errorf("error removing package file: %v", err)) + } + return &ExtractPackageResult{Path: path}, nil } diff --git a/internal/sfa/sfa.go b/internal/sfa/sfa.go index ea2011ffc..cf830c92d 100644 --- a/internal/sfa/sfa.go +++ b/internal/sfa/sfa.go @@ -67,9 +67,6 @@ func ExecuteActivities(ctx temporalsdk_workflow.Context, path string, key string return err } - // TODO: w.cleanUpPath() no longer exists. - // w.cleanUpPath(extractPackageRes.Path) - // Validate SIP structure. var checkStructureRes activities.CheckSipStructureResult err = temporalsdk_workflow.ExecuteActivity(withLocalActOpts(ctx), activities.CheckSipStructureName, &activities.CheckSipStructureParams{ @@ -106,9 +103,6 @@ func ExecuteActivities(ctx temporalsdk_workflow.Context, path string, key string return err } - // TODO: w.cleanUpPath() no longer exists. - // w.cleanUpPath(sipCreation.NewSipPath) - // We do this so that the code above only stops when a non-bussines error is found. if !allowedFileFormats.Ok { return activities.ErrIlegalFileFormat diff --git a/internal/workflow/processing.go b/internal/workflow/processing.go index b13be1085..0bd709d13 100644 --- a/internal/workflow/processing.go +++ b/internal/workflow/processing.go @@ -666,9 +666,6 @@ func (w *ProcessingWorkflow) transferAM(sessCtx temporalsdk_workflow.Context, ti return err } - // TODO: w.cleanUpPath() no longer exists. - // w.cleanUpPath(zipResult.Path) // Delete when workflow completes. - defer func() { if err != nil { err = errors.Join(err, sfa.SendToFailedSIPs(sessCtx, zipResult.Path, tinfo.req.Key))