@@ -583,8 +583,14 @@ func (t *Tree) assimilate(item scanItem) error {
583583 }
584584
585585 // assimilate new file
586- newId := uuid .New ().String ()
587- fi , attrs , err := t .updateFile (item .Path , newId , spaceID , nil )
586+ assimilationNode .nodeId = uuid .New ().String ()
587+ // re-lock with the new node ID
588+ unlockNew , err := t .lookup .MetadataBackend ().Lock (assimilationNode )
589+ if err != nil {
590+ return err
591+ }
592+ defer func () { _ = unlockNew () }()
593+ fi , attrs , err := t .updateFile (item .Path , assimilationNode .nodeId , spaceID , nil )
588594 if err != nil {
589595 return err
590596 }
@@ -602,7 +608,7 @@ func (t *Tree) assimilate(item scanItem) error {
602608 ResourceId : & provider.ResourceId {
603609 StorageId : t .options .MountID ,
604610 SpaceId : spaceID ,
605- OpaqueId : newId ,
611+ OpaqueId : assimilationNode . nodeId ,
606612 },
607613 }
608614 if fi .IsDir () {
@@ -929,7 +935,7 @@ func (t *Tree) WarmupIDCache(root string, assimilate, onlyDirty bool) error {
929935 // this id clashes with an existing id -> re-assimilate
930936 _ , err := os .Stat (previousPath )
931937 if err == nil {
932- _ = t .assimilate (scanItem {Path : path , Trigger : "warmup id cache - id clash" })
938+ _ = t .assimilate (scanItem {Path : path , Trigger : "warmup id cache - id clash, previous path: " + previousPath })
933939 }
934940 }
935941 if err := t .lookup .CacheID (context .Background (), spaceID , id , path ); err != nil {
0 commit comments