aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLouis <louis@chmn.me>2023-11-30 10:33:42 +0100
committerGitHub <noreply@github.com>2023-11-30 10:33:42 +0100
commitbdc7c64ec7afdb57ec3033f2b35f55747a9dbe31 (patch)
tree2d4906fe29f997c836d5960fd9edb84b9352233b /lib
parent7cc66998a2a0383b89e80a9e5c54d9848c539455 (diff)
parent2f6a4bf4a157accf923db341f3b2836a3aead3c9 (diff)
downloadnextcloud-server-bdc7c64ec7afdb57ec3033f2b35f55747a9dbe31.tar.gz
nextcloud-server-bdc7c64ec7afdb57ec3033f2b35f55747a9dbe31.zip
Merge pull request #41765 from nextcloud/artonge/feat/sync_live_photos
Synchronize operation on live photo files
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Node/HookConnector.php4
-rw-r--r--lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php23
-rw-r--r--lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php23
3 files changed, 48 insertions, 2 deletions
diff --git a/lib/private/Files/Node/HookConnector.php b/lib/private/Files/Node/HookConnector.php
index a8e76d95c22..f61eedee66e 100644
--- a/lib/private/Files/Node/HookConnector.php
+++ b/lib/private/Files/Node/HookConnector.php
@@ -133,7 +133,7 @@ class HookConnector {
$this->root->emit('\OC\Files', 'preDelete', [$node]);
$this->dispatcher->dispatch('\OCP\Files::preDelete', new GenericEvent($node));
- $event = new BeforeNodeDeletedEvent($node);
+ $event = new BeforeNodeDeletedEvent($node, $arguments['run']);
$this->dispatcher->dispatchTyped($event);
}
@@ -171,7 +171,7 @@ class HookConnector {
$this->root->emit('\OC\Files', 'preRename', [$source, $target]);
$this->dispatcher->dispatch('\OCP\Files::preRename', new GenericEvent([$source, $target]));
- $event = new BeforeNodeRenamedEvent($source, $target);
+ $event = new BeforeNodeRenamedEvent($source, $target, $arguments['run']);
$this->dispatcher->dispatchTyped($event);
}
diff --git a/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php b/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php
index 316a30fadd8..dd29a39a279 100644
--- a/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php
+++ b/lib/public/Files/Events/Node/BeforeNodeDeletedEvent.php
@@ -25,8 +25,31 @@ declare(strict_types=1);
*/
namespace OCP\Files\Events\Node;
+use Exception;
+use OCP\Files\Node;
+
/**
* @since 20.0.0
*/
class BeforeNodeDeletedEvent extends AbstractNodeEvent {
+ /**
+ * @since 20.0.0
+ */
+ public function __construct(Node $node, private bool &$run) {
+ parent::__construct($node);
+ }
+
+ /**
+ * @since 28.0.0
+ * @return never
+ */
+ public function abortOperation(\Throwable $ex = null) {
+ $this->stopPropagation();
+ $this->run = false;
+ if ($ex !== null) {
+ throw $ex;
+ } else {
+ throw new Exception('Operation aborted');
+ }
+ }
}
diff --git a/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php b/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php
index efbef03e383..c6876666713 100644
--- a/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php
+++ b/lib/public/Files/Events/Node/BeforeNodeRenamedEvent.php
@@ -25,8 +25,31 @@ declare(strict_types=1);
*/
namespace OCP\Files\Events\Node;
+use Exception;
+use OCP\Files\Node;
+
/**
* @since 20.0.0
*/
class BeforeNodeRenamedEvent extends AbstractNodesEvent {
+ /**
+ * @since 20.0.0
+ */
+ public function __construct(Node $source, Node $target, private bool &$run) {
+ parent::__construct($source, $target);
+ }
+
+ /**
+ * @since 28.0.0
+ * @return never
+ */
+ public function abortOperation(\Throwable $ex = null) {
+ $this->stopPropagation();
+ $this->run = false;
+ if ($ex !== null) {
+ throw $ex;
+ } else {
+ throw new Exception('Operation aborted');
+ }
+ }
}