diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-28 22:16:42 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-09-29 13:29:04 +0200 |
commit | e0c00af3bf63b41d4c47a8d0ae8ae137b05d5fd9 (patch) | |
tree | f52c6a1cd095b704359304a4e568a1e7b881e9c8 /lib/public | |
parent | a0b2297c536923867ed3f8e489dabe8a278ac0be (diff) | |
download | nextcloud-server-e0c00af3bf63b41d4c47a8d0ae8ae137b05d5fd9.tar.gz nextcloud-server-e0c00af3bf63b41d4c47a8d0ae8ae137b05d5fd9.zip |
fix(dav): Emit `BeforeZipCreatedEvent` when creating folder zip archivefix/bring-back-zip-event
This is required to not break behavior on zip download (apps should be able to react to zip download especially for shares).
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/Files/Events/BeforeZipCreatedEvent.php | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/lib/public/Files/Events/BeforeZipCreatedEvent.php b/lib/public/Files/Events/BeforeZipCreatedEvent.php index b55b36d3968..0363d385d36 100644 --- a/lib/public/Files/Events/BeforeZipCreatedEvent.php +++ b/lib/public/Files/Events/BeforeZipCreatedEvent.php @@ -10,23 +10,45 @@ declare(strict_types=1); namespace OCP\Files\Events; use OCP\EventDispatcher\Event; +use OCP\Files\Folder; /** + * This event is triggered before a archive is created when a user requested + * downloading a folder or multiple files. + * + * By setting `successful` to false the tar creation can be aborted and the download denied. + * * @since 25.0.0 */ class BeforeZipCreatedEvent extends Event { private string $directory; - private array $files; private bool $successful = true; private ?string $errorMessage = null; + private ?Folder $folder = null; /** + * @param list<string> $files * @since 25.0.0 + * @since 31.0.0 support `OCP\Files\Folder` as `$directory` parameter - passing a string is deprecated now */ - public function __construct(string $directory, array $files) { + public function __construct( + string|Folder $directory, + private array $files, + ) { parent::__construct(); - $this->directory = $directory; - $this->files = $files; + if ($directory instanceof Folder) { + $this->directory = $directory->getPath(); + $this->folder = $directory; + } else { + $this->directory = $directory; + } + } + + /** + * @since 31.0.0 + */ + public function getFolder(): ?Folder { + return $this->folder; } /** |