Skip to content

Commit

Permalink
Keep PREMIS files in SIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jraddaoui committed May 31, 2024
1 parent f7153f1 commit a900b97
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 43 deletions.
5 changes: 0 additions & 5 deletions cmd/worker/workercmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

"github.com/artefactual-sdps/temporal-activities/bagit"
"github.com/artefactual-sdps/temporal-activities/removefiles"
"github.com/go-logr/logr"
"go.artefactual.dev/tools/temporal"
temporalsdk_activity "go.temporal.io/sdk/activity"
Expand Down Expand Up @@ -80,10 +79,6 @@ func (m *Main) Run(ctx context.Context) error {
activities.NewTransformSIP().Execute,
temporalsdk_activity.RegisterOptions{Name: activities.TransformSIPName},
)
w.RegisterActivityWithOptions(
removefiles.NewActivity().Execute,
temporalsdk_activity.RegisterOptions{Name: removefiles.ActivityName},
)
w.RegisterActivityWithOptions(
bagit.NewCreateBagActivity(m.cfg.Bagit).Execute,
temporalsdk_activity.RegisterOptions{Name: bagit.CreateBagActivityName},
Expand Down
3 changes: 1 addition & 2 deletions internal/activities/transform_sip.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ func (a *TransformSIP) Execute(ctx context.Context, params *TransformSIPParams)
return err
}
if d.Name() == "Prozess_Digitalisierung_PREMIS.xml" {
// Adding the parent dir to the filename reduces the likelihood of filename
// conflicts and prevents deletion when all PREMIS files are deleted after.
// Adding the parent dir to the filename reduces the likelihood of filename conflicts.
dir := filepath.Base(filepath.Dir(p))
dest := filepath.Join(mdPath, fmt.Sprintf("Prozess_Digitalisierung_PREMIS_%s.xml", dir))
err := fsutil.Move(p, dest)
Expand Down
18 changes: 0 additions & 18 deletions internal/workflow/preprocessing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ import (
"errors"
"fmt"
"path/filepath"
"regexp"
"time"

"github.com/artefactual-sdps/temporal-activities/bagit"
"github.com/artefactual-sdps/temporal-activities/removefiles"
"go.artefactual.dev/tools/temporal"
temporalsdk_temporal "go.temporal.io/sdk/temporal"
temporalsdk_workflow "go.temporal.io/sdk/workflow"

"github.com/artefactual-sdps/preprocessing-sfa/internal/activities"
)

var premisRe *regexp.Regexp = regexp.MustCompile("(?i)_PREMIS.xml$")

type PreprocessingWorkflowParams struct {
RelativePath string
}
Expand Down Expand Up @@ -106,20 +102,6 @@ func (w *PreprocessingWorkflow) Execute(
return nil, e
}

// Remove PREMIS files.
var removeFiles removefiles.ActivityResult
e = temporalsdk_workflow.ExecuteActivity(
withLocalActOpts(ctx),
removefiles.ActivityName,
&removefiles.ActivityParams{
Path: localPath,
RemovePatterns: []*regexp.Regexp{premisRe},
},
).Get(ctx, &removeFiles)
if e != nil {
return nil, e
}

// Bag the SIP for Enduro processing.
var createBag bagit.CreateBagActivityResult
e = temporalsdk_workflow.ExecuteActivity(
Expand Down
18 changes: 0 additions & 18 deletions internal/workflow/preprocessing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package workflow_test

import (
"path/filepath"
"regexp"
"testing"

"github.com/artefactual-sdps/temporal-activities/bagit"
"github.com/artefactual-sdps/temporal-activities/removefiles"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
temporalsdk_activity "go.temporal.io/sdk/activity"
Expand All @@ -22,8 +20,6 @@ import (

const sharedPath = "/shared/path/"

var premisRe *regexp.Regexp = regexp.MustCompile("(?i)_PREMIS.xml$")

type PreprocessingTestSuite struct {
suite.Suite
temporalsdk_testsuite.WorkflowTestSuite
Expand Down Expand Up @@ -57,10 +53,6 @@ func (s *PreprocessingTestSuite) SetupTest(cfg config.Configuration) {
activities.NewTransformSIP().Execute,
temporalsdk_activity.RegisterOptions{Name: activities.TransformSIPName},
)
s.env.RegisterActivityWithOptions(
removefiles.NewActivity().Execute,
temporalsdk_activity.RegisterOptions{Name: removefiles.ActivityName},
)
s.env.RegisterActivityWithOptions(
bagit.NewCreateBagActivity(cfg.Bagit).Execute,
temporalsdk_activity.RegisterOptions{Name: bagit.CreateBagActivityName},
Expand Down Expand Up @@ -127,16 +119,6 @@ func (s *PreprocessingTestSuite) TestPreprocessingWorkflowSuccess() {
).Return(
&activities.TransformSIPResult{}, nil,
)
s.env.OnActivity(
removefiles.ActivityName,
sessionCtx,
&removefiles.ActivityParams{
Path: sipPath,
RemovePatterns: []*regexp.Regexp{premisRe},
},
).Return(
&removefiles.ActivityResult{}, nil,
)
s.env.OnActivity(
bagit.CreateBagActivityName,
sessionCtx,
Expand Down

0 comments on commit a900b97

Please sign in to comment.