Skip to content
Merged
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
6 changes: 6 additions & 0 deletions lib/private/Files/Storage/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
use OCP\Files\Storage\ILockingStorage;
use OCP\Files\Storage\IStorage;
use OCP\Files\Storage\IWriteStreamStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
use OCP\Server;
Expand Down Expand Up @@ -898,6 +899,11 @@ public function writeStream(string $path, $stream, int $size = null): int {

public function getDirectoryContent($directory): \Traversable {
$dh = $this->opendir($directory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question:

Suggested change
$dh = $this->opendir($directory);
try {
$dh = $this->opendir($directory);
} catch(\Exception $e) {
// Throw and take other actions?
}

Can't be caught? To capture the actual failure/error? (That might required an update to method opendir if the reading functions through meaningful error messages.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that method throws the exception should already propagate, don't think we need to wrap that.

The local storage implementation would already log an error but return false which just wasn't handled before.


if ($dh === false) {
throw new StorageNotAvailableException('Directory listing failed');
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially impacts all storage subsystems, since you put the change into Common.php . In particular, the sftp storage inherits the same implementation and breaks on sub-folders without sufficient permissions. Please revert that patch or move it to Local.php

if (is_resource($dh)) {
$basePath = rtrim($directory, '/');
while (($file = readdir($dh)) !== false) {
Expand Down