Skip to content

Commit

Permalink
Merge pull request #37624 from nextcloud/fix/logging-for-failed-fopen
Browse files Browse the repository at this point in the history
fix: log fopen calls when stream isn't available
  • Loading branch information
blizzz authored Jul 28, 2023
2 parents f3bdcfd + 70a6eee commit ff2b36a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/private/Streamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OCP\Files\NotPermittedException;
use OCP\IRequest;
use ownCloud\TarStreamer\TarStreamer;
use Psr\Log\LoggerInterface;
use ZipStreamer\ZipStreamer;

class Streamer {
Expand Down Expand Up @@ -122,10 +123,16 @@ public function addDirRecursive(string $dir, string $internalDir = ''): void {
$dirNode = $userFolder->get($dir);
$files = $dirNode->getDirectoryListing();

/** @var LoggerInterface $logger */
$logger = \OC::$server->query(LoggerInterface::class);
foreach ($files as $file) {
if ($file instanceof File) {
try {
$fh = $file->fopen('r');
if ($fh === false) {
$logger->error('Unable to open file for stream: ' . print_r($file, true));
continue;
}
} catch (NotPermittedException $e) {
continue;
}
Expand Down

0 comments on commit ff2b36a

Please sign in to comment.