Skip to content

Commit

Permalink
Add option to exclude hidden files from the transfer
Browse files Browse the repository at this point in the history
Co-authored-by: Jesús García Crespo <[email protected]>
  • Loading branch information
camlyall and sevein committed Sep 14, 2023
1 parent 7db1b6d commit 59d3bd0
Show file tree
Hide file tree
Showing 28 changed files with 769 additions and 104 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ gen-mock: $(MOCKGEN)
mockgen -typed -destination=./internal/collection/fake/mock_collection.go -package=fake github.com/artefactual-labs/enduro/internal/collection Service
mockgen -typed -destination=./internal/pipeline/fake/mock_pipeline.go -package=fake github.com/artefactual-labs/enduro/internal/pipeline Service
mockgen -typed -destination=./internal/watcher/fake/mock_watcher.go -package=fake github.com/artefactual-labs/enduro/internal/watcher Service
mockgen -typed -destination=./internal/watcher/fake/mock_watcher_unit.go -package=fake github.com/artefactual-labs/enduro/internal/watcher Watcher

temporal: # @HELP Runs a development instance of Temporal.
temporal: PORT := 55555
Expand Down
2 changes: 2 additions & 0 deletions enduro.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pipeline = "am"
retentionPeriod = "10s"
stripTopLevelDir = true
rejectDuplicates = false
excludeHiddenFiles = false
transferType = "standard"

[[watcher.filesystem]]
Expand All @@ -46,6 +47,7 @@ completedDir = "./hack/landfill"
ignore = '(^\.gitkeep)|(^*\.mft)$'
stripTopLevelDir = true
rejectDuplicates = false
excludeHiddenFiles = false
transferType = "standard"

[[pipeline]]
Expand Down
1 change: 1 addition & 0 deletions internal/api/design/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var _ = Service("batch", func() {
Attribute("completed_dir", String)
Attribute("retention_period", String)
Attribute("reject_duplicates", Boolean, func() { Default(false) })
Attribute("exclude_hidden_files", Boolean, func() { Default(false) })
Attribute("transfer_type", String)
Attribute("process_name_metadata", Boolean, func() { Default(false) })
Attribute("depth", Int, func() {
Expand Down
1 change: 1 addition & 0 deletions internal/api/gen/batch/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion internal/api/gen/http/batch/client/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions internal/api/gen/http/batch/client/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions internal/api/gen/http/batch/server/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/api/gen/http/cli/enduro/cli.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions internal/api/gen/http/openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/api/gen/http/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions internal/api/gen/http/openapi3.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions internal/api/gen/http/openapi3.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion internal/batch/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ func (s *batchImpl) Submit(ctx context.Context, payload *goabatch.SubmitPayload)
}
input.RetentionPeriod = &dur
}
input.RejectDuplicates = payload.RejectDuplicates
if payload.TransferType != nil {
input.TransferType = *payload.TransferType
}
input.RejectDuplicates = payload.RejectDuplicates
input.ExcludeHiddenFiles = payload.ExcludeHiddenFiles
input.MetadataConfig.ProcessNameMetadata = payload.ProcessNameMetadata
input.Depth = int32(payload.Depth)
opts := temporalsdk_client.StartWorkflowOptions{
Expand Down
40 changes: 21 additions & 19 deletions internal/batch/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ type BatchProgress struct {
}

type BatchWorkflowInput struct {
Path string
PipelineName string
ProcessingConfig string
CompletedDir string
RetentionPeriod *time.Duration
RejectDuplicates bool
TransferType string
MetadataConfig metadata.Config
Depth int32
Path string
PipelineName string
ProcessingConfig string
CompletedDir string
RetentionPeriod *time.Duration
RejectDuplicates bool
ExcludeHiddenFiles bool
TransferType string
MetadataConfig metadata.Config
Depth int32
}

func BatchWorkflow(ctx temporalsdk_workflow.Context, params BatchWorkflowInput) error {
Expand Down Expand Up @@ -89,16 +90,17 @@ func (a *BatchActivity) Execute(ctx context.Context, params BatchWorkflowInput)
}

req := collection.ProcessingWorkflowRequest{
BatchDir: filepath.Dir(path),
Key: entry.Name(),
IsDir: entry.IsDir(),
PipelineNames: pipelines,
ProcessingConfig: params.ProcessingConfig,
CompletedDir: params.CompletedDir,
RetentionPeriod: params.RetentionPeriod,
RejectDuplicates: params.RejectDuplicates,
TransferType: params.TransferType,
MetadataConfig: params.MetadataConfig,
BatchDir: filepath.Dir(path),
Key: entry.Name(),
IsDir: entry.IsDir(),
PipelineNames: pipelines,
ProcessingConfig: params.ProcessingConfig,
CompletedDir: params.CompletedDir,
RetentionPeriod: params.RetentionPeriod,
RejectDuplicates: params.RejectDuplicates,
ExcludeHiddenFiles: params.ExcludeHiddenFiles,
TransferType: params.TransferType,
MetadataConfig: params.MetadataConfig,
}

_ = a.batchsvc.InitProcessingWorkflow(ctx, &req)
Expand Down
3 changes: 3 additions & 0 deletions internal/collection/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ type ProcessingWorkflowRequest struct {
// Whether we reject duplicates based on name (key).
RejectDuplicates bool

// Whether we exclude hidden files from submission.
ExcludeHiddenFiles bool

// Transfer type.
TransferType string

Expand Down
24 changes: 13 additions & 11 deletions internal/watcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ type FilesystemConfig struct {
Inotify bool
Ignore string

Pipeline []string
RetentionPeriod *time.Duration
CompletedDir string
StripTopLevelDir bool
RejectDuplicates bool
TransferType string
Pipeline []string
RetentionPeriod *time.Duration
CompletedDir string
StripTopLevelDir bool
RejectDuplicates bool
ExcludeHiddenFiles bool
TransferType string
}

// See minio.go for more.
Expand All @@ -55,9 +56,10 @@ type MinioConfig struct {
Token string
Bucket string

Pipeline []string
RetentionPeriod *time.Duration
StripTopLevelDir bool
RejectDuplicates bool
TransferType string
Pipeline []string
RetentionPeriod *time.Duration
StripTopLevelDir bool
RejectDuplicates bool
ExcludeHiddenFiles bool
TransferType string
}
22 changes: 13 additions & 9 deletions internal/watcher/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type BlobEvent struct {
// Whether duplicates are rejected or not.
RejectDuplicates bool

// Whether hidden files are exluded or not.
ExcludeHiddenFiles bool

// Which transfer type to use in Archivemaitca.
TransferType string

Expand All @@ -47,15 +50,16 @@ type BlobEvent struct {

func NewBlobEvent(w Watcher, key string, isDir bool) *BlobEvent {
return &BlobEvent{
WatcherName: w.String(),
PipelineName: w.Pipelines(),
RetentionPeriod: w.RetentionPeriod(),
CompletedDir: w.CompletedDir(),
StripTopLevelDir: w.StripTopLevelDir(),
RejectDuplicates: w.RejectDuplicates(),
TransferType: w.TransferType(),
Key: key,
IsDir: isDir,
WatcherName: w.String(),
PipelineName: w.Pipelines(),
RetentionPeriod: w.RetentionPeriod(),
CompletedDir: w.CompletedDir(),
StripTopLevelDir: w.StripTopLevelDir(),
RejectDuplicates: w.RejectDuplicates(),
ExcludeHiddenFiles: w.ExcludeHiddenFiles(),
TransferType: w.TransferType(),
Key: key,
IsDir: isDir,
}
}

Expand Down
Loading

0 comments on commit 59d3bd0

Please sign in to comment.