Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 8 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,17 @@ public function handle(Event $event): void {
return;
}

/** @psalm-suppress DeprecatedMethod should be migrated to getFolder but for now it would just duplicate code */
$dir = $event->getDirectory();
$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 = '';
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 @@ public function __construct(
) {
parent::__construct();
if ($directory instanceof Folder) {
$this->directory = $directory->getPath();
$this->folder = $directory;
} else {
$this->directory = $directory;
Expand All @@ -53,8 +53,13 @@ public function getFolder(): ?Folder {

/**
* @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;
}

Expand Down
Loading