From a900b97939546b2f6144c709254770cf5abfbb99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Raddaoui=20Mar=C3=ADn?= Date: Fri, 31 May 2024 14:45:41 +0200 Subject: [PATCH] Keep PREMIS files in SIP --- cmd/worker/workercmd/cmd.go | 5 ----- internal/activities/transform_sip.go | 3 +-- internal/workflow/preprocessing.go | 18 ------------------ internal/workflow/preprocessing_test.go | 18 ------------------ 4 files changed, 1 insertion(+), 43 deletions(-) diff --git a/cmd/worker/workercmd/cmd.go b/cmd/worker/workercmd/cmd.go index 2219ba8d..fd73eef7 100644 --- a/cmd/worker/workercmd/cmd.go +++ b/cmd/worker/workercmd/cmd.go @@ -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" @@ -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}, diff --git a/internal/activities/transform_sip.go b/internal/activities/transform_sip.go index e495bf78..5cec4711 100644 --- a/internal/activities/transform_sip.go +++ b/internal/activities/transform_sip.go @@ -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) diff --git a/internal/workflow/preprocessing.go b/internal/workflow/preprocessing.go index 0a917496..bbb3aca5 100644 --- a/internal/workflow/preprocessing.go +++ b/internal/workflow/preprocessing.go @@ -4,11 +4,9 @@ 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" @@ -16,8 +14,6 @@ import ( "github.com/artefactual-sdps/preprocessing-sfa/internal/activities" ) -var premisRe *regexp.Regexp = regexp.MustCompile("(?i)_PREMIS.xml$") - type PreprocessingWorkflowParams struct { RelativePath string } @@ -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( diff --git a/internal/workflow/preprocessing_test.go b/internal/workflow/preprocessing_test.go index 4683cf81..4def859d 100644 --- a/internal/workflow/preprocessing_test.go +++ b/internal/workflow/preprocessing_test.go @@ -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" @@ -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 @@ -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}, @@ -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,