Skip to content

Commit c47af9f

Browse files
authored
Merge pull request #57663 from nextcloud/backport/57573/stable32
2 parents 753af54 + fb673b0 commit c47af9f

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

apps/files_sharing/lib/Listener/BeforeZipCreatedListener.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ public function handle(Event $event): void {
3232
return;
3333
}
3434

35+
/** @psalm-suppress DeprecatedMethod should be migrated to getFolder but for now it would just duplicate code */
3536
$dir = $event->getDirectory();
3637
$files = $event->getFiles();
3738

38-
$pathsToCheck = [];
39-
foreach ($files as $file) {
40-
$pathsToCheck[] = $dir . '/' . $file;
39+
if (empty($files)) {
40+
$pathsToCheck = [$dir];
41+
} else {
42+
$pathsToCheck = [];
43+
foreach ($files as $file) {
44+
$pathsToCheck[] = $dir . '/' . $file;
45+
}
4146
}
4247

4348
// Check only for user/group shares. Don't restrict e.g. share links

apps/files_sharing/lib/ViewOnly.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(
2424
}
2525

2626
/**
27-
* @param string[] $pathsToCheck
27+
* @param string[] $pathsToCheck paths to check, relative to the user folder
2828
* @return bool
2929
*/
3030
public function check(array $pathsToCheck): bool {

lib/public/Files/Events/BeforeZipCreatedEvent.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
* @since 25.0.0
2222
*/
2323
class BeforeZipCreatedEvent extends Event {
24-
private string $directory;
24+
private string $directory = '';
2525
private bool $successful = true;
2626
private ?string $errorMessage = null;
2727
private ?Folder $folder = null;
2828

2929
/**
30+
* @param string|Folder $directory Folder instance, or (deprecated) string path relative to user folder
3031
* @param list<string> $files
3132
* @since 25.0.0
3233
* @since 31.0.0 support `OCP\Files\Folder` as `$directory` parameter - passing a string is deprecated now
@@ -37,7 +38,6 @@ public function __construct(
3738
) {
3839
parent::__construct();
3940
if ($directory instanceof Folder) {
40-
$this->directory = $directory->getPath();
4141
$this->folder = $directory;
4242
} else {
4343
$this->directory = $directory;
@@ -53,8 +53,13 @@ public function getFolder(): ?Folder {
5353

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

0 commit comments

Comments
 (0)