Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
Remove original after extraction and SIP creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jraddaoui committed Dec 4, 2023
1 parent 9906473 commit d40501a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
8 changes: 8 additions & 0 deletions internal/sfa/activities/create_sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package activities
import (
"context"
"errors"
"fmt"
"os"
"os/exec"

"go.artefactual.dev/tools/temporal"
)

const SipCreationName = "sip-creation"
Expand Down Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions internal/sfa/activities/extract_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 0 additions & 6 deletions internal/sfa/sfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions internal/workflow/processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit d40501a

Please sign in to comment.