Merge pull request #37624 from nextcloud/fix/logging-for-failed-fopen

fix: log fopen calls when stream isn't available
This commit is contained in:
Arthur Schiwon 2023-07-28 12:59:52 +02:00 committed by GitHub
commit ff2b36ad52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,7 @@ use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\IRequest;
use ownCloud\TarStreamer\TarStreamer;
use Psr\Log\LoggerInterface;
use ZipStreamer\ZipStreamer;
class Streamer {
@ -122,10 +123,16 @@ class Streamer {
$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;
}