Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Feb 6, 2024
1 parent e4f08da commit f485344
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions apps/files/lib/Listener/SyncLivePhotosListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Cache\CacheEntryRemovedEvent;
use OCP\Files\Events\Node\AbstractNodesEvent;
use OCP\Files\Events\Node\BeforeNodeCopiedEvent;
use OCP\Files\Events\Node\BeforeNodeDeletedEvent;
use OCP\Files\Events\Node\BeforeNodeRenamedEvent;
Expand Down Expand Up @@ -105,7 +106,7 @@ public function handle(Event $event): void {
* of pending renames inside the 'pendingRenames' property,
* to prevent infinite recursive.
*/
private function handleMove(Event $event, Node $peerFile, bool $prepForCopyOnly = false): void {
private function handleMove(AbstractNodesEvent $event, Node $peerFile, bool $prepForCopyOnly = false): void {
$sourceFile = $event->getSource();
$targetFile = $event->getTarget();
$targetParent = $targetFile->getParent();
Expand All @@ -120,30 +121,29 @@ private function handleMove(Event $event, Node $peerFile, bool $prepForCopyOnly
try {
$targetParent->get($targetName);
$event->abortOperation(new NotPermittedException("A file already exist at destination path of the Live Photo"));

Check failure on line 123 in apps/files/lib/Listener/SyncLivePhotosListener.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedMethod

apps/files/lib/Listener/SyncLivePhotosListener.php:123:12: UndefinedMethod: Method OCP\Files\Events\Node\AbstractNodesEvent::abortOperation does not exist (see https://psalm.dev/022)
} catch (NotFoundException $ex) {
} catch (NotFoundException) {
}

$peerTargetName = substr($targetName, 0, -strlen($sourceExtension)) . $peerFileExtension;
try {
$targetParent->get($peerTargetName);
$event->abortOperation(new NotPermittedException("A file already exist at destination path of the Live Photo"));

Check failure on line 130 in apps/files/lib/Listener/SyncLivePhotosListener.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedMethod

apps/files/lib/Listener/SyncLivePhotosListener.php:130:12: UndefinedMethod: Method OCP\Files\Events\Node\AbstractNodesEvent::abortOperation does not exist (see https://psalm.dev/022)
} catch (NotFoundException $ex) {
} catch (NotFoundException) {
}

// in case the rename was initiated from this listener, we stop right now
if (array_key_exists($peerFile->getId(), $this->pendingRenames)) {
if ($prepForCopyOnly || in_array($peerFile->getId(), $this->pendingRenames)) {
return;
}

$this->pendingRenames[$sourceFile->getId()] = $peerFile->getId();
$this->pendingRenames[] = $sourceFile->getId();

Check failure on line 139 in apps/files/lib/Listener/SyncLivePhotosListener.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

InvalidPropertyAssignmentValue

apps/files/lib/Listener/SyncLivePhotosListener.php:139:3: InvalidPropertyAssignmentValue: $this->pendingRenames with declared type 'array<int, string>' cannot be assigned type 'non-empty-array<int, int|string>' (see https://psalm.dev/145)

Check failure

Code scanning / Psalm

InvalidPropertyAssignmentValue Error

$this->pendingRenames with declared type 'array<int, string>' cannot be assigned type 'non-empty-array<int, int|string>'
try {
if (!$prepForCopyOnly) {
$peerFile->move($targetParent->getPath() . '/' . $peerTargetName);
}
} catch (\Throwable $ex) {
$event->abortOperation($ex);

Check failure on line 143 in apps/files/lib/Listener/SyncLivePhotosListener.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedMethod

apps/files/lib/Listener/SyncLivePhotosListener.php:143:12: UndefinedMethod: Method OCP\Files\Events\Node\AbstractNodesEvent::abortOperation does not exist (see https://psalm.dev/022)
}
unset($this->pendingRenames[$sourceFile->getId()]);

array_diff($this->pendingRenames, [$sourceFile->getId()]);
}


Expand Down

0 comments on commit f485344

Please sign in to comment.