@@ -37,6 +37,8 @@ class SyncLivePhotosListener implements IEventListener {
3737 private array $ pendingRenames = [];
3838 /** @var Array<int, bool> */
3939 private array $ pendingDeletion = [];
40+ /** @var Array<int> */
41+ private array $ pendingCopies = [];
4042
4143 public function __construct (
4244 private ?Folder $ userFolder ,
@@ -153,6 +155,12 @@ private function handleCopy(File $sourceFile, File $targetFile, File $peerFile):
153155 $ targetName = $ targetFile ->getName ();
154156 $ peerTargetName = substr ($ targetName , 0 , -strlen ($ sourceExtension )) . $ peerFileExtension ;
155157
158+ // in case the copy was initiated from this listener, we stop right now
159+ if (in_array ($ peerFile ->getId (), $ this ->pendingCopies )) {
160+ return ;
161+ }
162+
163+ $ this ->pendingCopies [] = $ sourceFile ->getId ();
156164
157165 if ($ targetParent ->nodeExists ($ peerTargetName )) {
158166 // If the copy was a folder copy, then the peer file already exists.
@@ -172,6 +180,8 @@ private function handleCopy(File $sourceFile, File $targetFile, File $peerFile):
172180 $ peerMetadata ->setStorageId ($ targetPeerFile ->getStorage ()->getCache ()->getNumericStorageId ());
173181 $ peerMetadata ->setString ('files-live-photo ' , (string )$ targetFile ->getId ());
174182 $ this ->filesMetadataManager ->saveMetadata ($ peerMetadata );
183+
184+ $ this ->pendingCopies = array_diff ($ this ->pendingCopies , [$ sourceFile ->getId ()]);
175185 }
176186
177187 /**
0 commit comments