MCPcopy Create free account
hub / github.com/pydio/cells / processCreateFolder

Method processCreateFolder

common/sync/proc/create-folder.go:34–69  ·  view source on GitHub ↗
(cancelCtx context.Context, operation merger.Operation, operationId string, pg chan int64)

Source from the content-addressed store, hash-verified

32)
33
34func (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}

Callers

nothing calls this directly

Calls 15

LoggerMethod · 0.95
GetRefPathMethod · 0.65
CreateContextMethod · 0.65
LockFileMethod · 0.65
UnlockFileMethod · 0.65
TargetMethod · 0.65
SourceMethod · 0.65
LoadNodeByUuidMethod · 0.65
GetUuidMethod · 0.65
GetNodeMethod · 0.65
InfoMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected