Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added IgnoreMissingObjects to ignore objects that were not found #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func initConfig() {
viper.SetDefault("options.finderNumber", dth.DefaultFinderNumber)
viper.SetDefault("options.workerNumber", dth.DefaultWorkerNumber)
viper.SetDefault("options.includeMetadata", false)
viper.SetDefault("options.ignoreMissingObjects", false)

viper.BindEnv("srcType", "SOURCE_TYPE")
viper.BindEnv("srcBucket", "SRC_BUCKET")
Expand Down Expand Up @@ -135,14 +136,15 @@ func initConfig() {
}

options := &dth.JobOptions{
ChunkSize: viper.GetInt("options.chunkSize"),
MultipartThreshold: viper.GetInt("options.multipartThreshold"),
MaxKeys: viper.GetInt32("options.maxKeys"),
MessageBatchSize: viper.GetInt("options.messageBatchSize"),
FinderDepth: viper.GetInt("options.finderDepth"),
FinderNumber: viper.GetInt("options.finderNumber"),
WorkerNumber: viper.GetInt("options.workerNumber"),
IncludeMetadata: viper.GetBool("options.includeMetadata"),
ChunkSize: viper.GetInt("options.chunkSize"),
MultipartThreshold: viper.GetInt("options.multipartThreshold"),
MaxKeys: viper.GetInt32("options.maxKeys"),
MessageBatchSize: viper.GetInt("options.messageBatchSize"),
FinderDepth: viper.GetInt("options.finderDepth"),
FinderNumber: viper.GetInt("options.finderNumber"),
WorkerNumber: viper.GetInt("options.worker-Number"),
IncludeMetadata: viper.GetBool("options.includeMetadata"),
IgnoreMissingObjects: viper.GetBool("options.ignoreMissingObjects"),
}

cfg = &dth.JobConfig{
Expand Down
2 changes: 1 addition & 1 deletion dth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const (
type JobOptions struct {
ChunkSize, MultipartThreshold, MessageBatchSize, FinderDepth, FinderNumber, WorkerNumber int
MaxKeys int32
IncludeMetadata bool
IncludeMetadata, IgnoreMissingObjects bool
}

// JobConfig is General Job Info
Expand Down
17 changes: 17 additions & 0 deletions dth/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,23 @@ func (w *Worker) Run(ctx context.Context) {
continue
}

if w.cfg.IgnoreMissingObjects {
// Delete message if object does not exist.
// This might happen if the object was deleted in the meantime.
meta := w.srcClient.HeadObject(ctx, &obj.Key)
if meta == nil {
log.Printf("Object not found %s/%s\n", w.cfg.SrcBucket, obj.Key)
res := &TransferResult{
status: "NOT_FOUND",
etag: nil,
err: nil,
}
w.db.UpdateItem(ctx, &obj.Key, res)
w.sqs.DeleteMessage(ctx, rh)
continue
}
}

destKey := appendPrefix(&obj.Key, &w.cfg.DestPrefix)

if action == Transfer {
Expand Down