From 1bb40c4c3f1994458d7abeba3740a910490f324b Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 18 Oct 2024 13:55:21 +0300 Subject: [PATCH] check already copied files and skip them (#69) --- pkg/proc/interaction.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/proc/interaction.go b/pkg/proc/interaction.go index 0828da5..8b3f491 100644 --- a/pkg/proc/interaction.go +++ b/pkg/proc/interaction.go @@ -233,6 +233,15 @@ func ProcessCopyExtended(msg message.CopyMessage, s storage.StorageInteractor, c return err } + copied, err := s.ListPath(msg.Name) + if err != nil { + return err + } + copiedSizes := make(map[string]int64) + for _, c := range copied { + copiedSizes[c.Path] = c.Size + } + var failed []*object.ObjectInfo retryCount := 0 for len(objectMetas) > 0 && retryCount < 10 { @@ -241,6 +250,11 @@ func ProcessCopyExtended(msg message.CopyMessage, s storage.StorageInteractor, c path := strings.TrimPrefix(objectMetas[i].Path, instanceCnf.StorageCnf.StoragePrefix) reworked := ReworkFileName(path) if _, ok := vi[reworked]; !ok { + ylogger.Zero.Debug().Str("object path", objectMetas[i].Path).Msg("not in virtual index, skipping...") + continue + } + if size, ok := copiedSizes[objectMetas[i].Path]; ok && size == objectMetas[i].Size { + ylogger.Zero.Debug().Str("object path", objectMetas[i].Path).Int64("object size", objectMetas[i].Size).Msg("already copied, skipping...") continue }