@@ -37,6 +37,7 @@ class SyncLivePhotosListener implements IEventListener {
3737 private array $ pendingRenames = [];
3838 /** @var Array<int, bool> */
3939 private array $ pendingDeletion = [];
40+ private string $ copyTargetPath = '' ;
4041
4142 public function __construct (
4243 private ?Folder $ userFolder ,
@@ -53,6 +54,10 @@ public function handle(Event $event): void {
5354 }
5455
5556 if ($ event instanceof BeforeNodeCopiedEvent || $ event instanceof NodeCopiedEvent) {
57+ if ($ this ->copyTargetPath === $ event ->getTarget ()->getPath ()) {
58+ $ this ->inCopyEvent = '' ;
59+ return ;
60+ }
5661 $ this ->handleCopyRecursive ($ event , $ event ->getSource (), $ event ->getTarget ());
5762 } else {
5863 $ peerFileId = null ;
@@ -158,8 +163,10 @@ private function handleCopy(File $sourceFile, File $targetFile, File $peerFile):
158163 // If the copy was a folder copy, then the peer file already exists.
159164 $ targetPeerFile = $ targetParent ->get ($ peerTargetName );
160165 } else {
166+ // Register the target path so we can ignore copy events for this copy.
167+ $ this ->copyTargetPath = $ targetParent ->getPath () . '/ ' . $ peerTargetName ;
161168 // If the copy was a file copy, then we need to create the peer file.
162- $ targetPeerFile = $ peerFile ->copy ($ targetParent -> getPath () . ' / ' . $ peerTargetName );
169+ $ targetPeerFile = $ peerFile ->copy ($ this -> copyTargetPath );
163170 }
164171
165172 /** @var FilesMetadata $targetMetadata */
0 commit comments