Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/files_sharing/lib/Listener/BeforeZipCreatedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@
return;
}

$dir = $event->getDirectory();

Check failure on line 35 in apps/files_sharing/lib/Listener/BeforeZipCreatedListener.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

DeprecatedMethod

apps/files_sharing/lib/Listener/BeforeZipCreatedListener.php:35:18: DeprecatedMethod: The method OCP\Files\Events\BeforeZipCreatedEvent::getDirectory has been marked as deprecated (see https://psalm.dev/001)
$files = $event->getFiles();

$pathsToCheck = [];
foreach ($files as $file) {
$pathsToCheck[] = $dir . '/' . $file;
if (empty($files)) {
$pathsToCheck = [$dir];
} else {
$pathsToCheck = [];
foreach ($files as $file) {
$pathsToCheck[] = $dir . '/' . $file;
}
}

// Check only for user/group shares. Don't restrict e.g. share links
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/ViewOnly.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(
}

/**
* @param string[] $pathsToCheck
* @param string[] $pathsToCheck paths to check, relative to the user folder
* @return bool
*/
public function check(array $pathsToCheck): bool {
Expand Down
9 changes: 7 additions & 2 deletions lib/public/Files/Events/BeforeZipCreatedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
* @since 25.0.0
*/
class BeforeZipCreatedEvent extends Event {
private string $directory;
private ?string $directory = null;
private bool $successful = true;
private ?string $errorMessage = null;
private ?Folder $folder = null;

/**
* @param string|Folder $directory Folder instance, or (deprecated) string path relative to user folder
* @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
Expand All @@ -37,7 +38,6 @@
) {
parent::__construct();
if ($directory instanceof Folder) {
$this->directory = $directory->getPath();
$this->folder = $directory;
} else {
$this->directory = $directory;
Expand All @@ -53,9 +53,14 @@

/**
* @since 25.0.0
* @deprecated 33.0.0 Use getFolder instead and use node API
* @return string returns folder path relative to user folder
*/
public function getDirectory(): string {
if ($this->folder instanceof Folder) {
return preg_replace('|^/[^/]+/files/|', '/', $this->folder->getPath());
}
return $this->directory;

Check failure on line 63 in lib/public/Files/Events/BeforeZipCreatedEvent.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-ocp

NullableReturnStatement

lib/public/Files/Events/BeforeZipCreatedEvent.php:63:10: NullableReturnStatement: The declared return type 'string' for OCP\Files\Events\BeforeZipCreatedEvent::getDirectory is not nullable, but the function returns 'null|string' (see https://psalm.dev/139)

Check failure on line 63 in lib/public/Files/Events/BeforeZipCreatedEvent.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

NullableReturnStatement

lib/public/Files/Events/BeforeZipCreatedEvent.php:63:10: NullableReturnStatement: The declared return type 'string' for OCP\Files\Events\BeforeZipCreatedEvent::getDirectory is not nullable, but the function returns 'null|string' (see https://psalm.dev/139)
}

/**
Expand Down
Loading