mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #57573 from nextcloud/fix/fix-beforezipcreatedlistener
fix(files_sharing): Fix BeforeZipCreatedListener path handling
This commit is contained in:
commit
a467589328
3 changed files with 16 additions and 6 deletions
|
|
@ -32,12 +32,17 @@ class BeforeZipCreatedListener implements IEventListener {
|
|||
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
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class ViewOnly {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string[] $pathsToCheck
|
||||
* @param string[] $pathsToCheck paths to check, relative to the user folder
|
||||
* @return bool
|
||||
*/
|
||||
public function check(array $pathsToCheck): bool {
|
||||
|
|
|
|||
|
|
@ -21,12 +21,13 @@ use OCP\Files\Folder;
|
|||
* @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
|
||||
|
|
@ -37,7 +38,6 @@ class BeforeZipCreatedEvent extends Event {
|
|||
) {
|
||||
parent::__construct();
|
||||
if ($directory instanceof Folder) {
|
||||
$this->directory = $directory->getPath();
|
||||
$this->folder = $directory;
|
||||
} else {
|
||||
$this->directory = $directory;
|
||||
|
|
@ -53,8 +53,13 @@ class BeforeZipCreatedEvent extends Event {
|
|||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue