aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas <jonas@freesources.org>2025-05-27 10:05:02 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2025-05-28 11:50:12 +0000
commit6bca885efe2e1a0c5f92aae3551cb213dc58d0a3 (patch)
tree320f1d46aa59df5d6b5f44e0e37adb2d47dd8a6d
parented492c5c70bd099889f8389bfe881e55f7d4921e (diff)
downloadnextcloud-server-backport/52996/stable31.tar.gz
nextcloud-server-backport/52996/stable31.zip
fix(SyncLivePhotosListener): Don't handle copy event emitted from usbackport/52996/stable31
Running $peerFile->copy() causes a second BeforeNodeCopiedEvent now, which we don't want to handle. Signed-off-by: Jonas <jonas@freesources.org>
-rw-r--r--apps/files/lib/Listener/SyncLivePhotosListener.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/files/lib/Listener/SyncLivePhotosListener.php b/apps/files/lib/Listener/SyncLivePhotosListener.php
index 6334e5d16a6..b6773e8c452 100644
--- a/apps/files/lib/Listener/SyncLivePhotosListener.php
+++ b/apps/files/lib/Listener/SyncLivePhotosListener.php
@@ -37,6 +37,8 @@ class SyncLivePhotosListener implements IEventListener {
private array $pendingRenames = [];
/** @var Array<int, bool> */
private array $pendingDeletion = [];
+ /** @var Array<int> */
+ private array $pendingCopies = [];
public function __construct(
private ?Folder $userFolder,
@@ -153,7 +155,6 @@ class SyncLivePhotosListener implements IEventListener {
$targetName = $targetFile->getName();
$peerTargetName = substr($targetName, 0, -strlen($sourceExtension)) . $peerFileExtension;
-
if ($targetParent->nodeExists($peerTargetName)) {
// If the copy was a folder copy, then the peer file already exists.
$targetPeerFile = $targetParent->get($peerTargetName);
@@ -225,6 +226,11 @@ class SyncLivePhotosListener implements IEventListener {
$this->handleCopyRecursive($event, $sourceChild, $targetChild);
}
} elseif ($sourceNode instanceof File && $targetNode instanceof File) {
+ // in case the copy was initiated from this listener, we stop right now
+ if (in_array($sourceNode->getId(), $this->pendingCopies)) {
+ return;
+ }
+
$peerFileId = $this->livePhotosService->getLivePhotoPeerId($sourceNode->getId());
if ($peerFileId === null) {
return;
@@ -234,11 +240,13 @@ class SyncLivePhotosListener implements IEventListener {
return;
}
+ $this->pendingCopies[] = $peerFileId;
if ($event instanceof BeforeNodeCopiedEvent) {
$this->runMoveOrCopyChecks($sourceNode, $targetNode, $peerFile);
} elseif ($event instanceof NodeCopiedEvent) {
$this->handleCopy($sourceNode, $targetNode, $peerFile);
}
+ $this->pendingCopies = array_diff($this->pendingCopies, [$peerFileId]);
} else {
throw new Exception('Source and target type are not matching');
}