(cancelCtx context.Context, operation merger.Operation, operationId string, pg chan int64)
| 32 | ) |
| 33 | |
| 34 | func (pr *Processor) processCreateFolder(cancelCtx context.Context, operation merger.Operation, operationId string, pg chan int64) error { |
| 35 | |
| 36 | pg <- 1 |
| 37 | localPath := operation.GetRefPath() |
| 38 | ctx := operation.CreateContext(pr.GlobalContext) |
| 39 | if pr.Locker != nil { |
| 40 | pr.Locker.LockFile(operation, localPath, operationId) |
| 41 | defer pr.Locker.UnlockFile(operation, localPath) |
| 42 | } |
| 43 | provider, ok1 := operation.Target().(model.UuidProvider) |
| 44 | receiver, ok2 := operation.Source().(model.UuidReceiver) |
| 45 | if ok1 && ok2 { |
| 46 | if sameIdNode, e := provider.LoadNodeByUuid(ctx, operation.GetNode().GetUuid()); e == nil && sameIdNode != nil { |
| 47 | pr.Logger().Info("Node found with same UUID", zap.String("local", localPath), sameIdNode.ZapPath()) |
| 48 | if sameIdNode.GetPath() == localPath { |
| 49 | // This is the same node, it already exists! Ignore operation |
| 50 | pr.Logger().Info("CreateFolder: already exists with same UUID, ignoring!", zap.String("refPath", operation.GetRefPath())) |
| 51 | return nil |
| 52 | } |
| 53 | // This is a duplicate! We have to refresh .pydio content now |
| 54 | newNode, er := receiver.UpdateNodeUuid(ctx, &tree.Node{Path: localPath}) |
| 55 | if er == nil { |
| 56 | pr.Logger().Info("Refreshed folder on source as Uuid was a duplicate.") |
| 57 | operation.SetNode(newNode) |
| 58 | } else { |
| 59 | pr.Logger().Info("Error while trying to refresh folder Uuid on source", zap.Error(er)) |
| 60 | return er |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | err := operation.Target().CreateNode(ctx, operation.GetNode(), false) |
| 65 | if err != nil && strings.Contains(string(err.Error()), "Duplicate entry") { |
| 66 | pr.Logger().Error("Duplicate UUID found, we should have refreshed uuids on source?", zap.Error(err)) |
| 67 | } |
| 68 | return err |
| 69 | } |
nothing calls this directly
no test coverage detected