Skip to content

Commit 07bf009

Browse files
Merge pull request nextcloud#53426 from nextcloud/smb-open-failure-log
feat: improve logging of fopen failures for smb
2 parents 4593b4f + 4242520 commit 07bf009

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • apps/files_external/lib/Lib/Storage

apps/files_external/lib/Lib/Storage/SMB.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private function getACL(IFileInfo $file): ?ACL {
198198
try {
199199
$acls = $file->getAcls();
200200
} catch (Exception $e) {
201-
$this->logger->error('Error while getting file acls', ['exception' => $e]);
201+
$this->logger->warning('Error while getting file acls', ['exception' => $e]);
202202
return null;
203203
}
204204
foreach ($acls as $user => $acl) {
@@ -426,6 +426,7 @@ public function fopen(string $path, string $mode) {
426426
case 'r':
427427
case 'rb':
428428
if (!$this->file_exists($path)) {
429+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', file doesn\'t exist.');
429430
return false;
430431
}
431432
return $this->share->read($fullPath);
@@ -453,11 +454,13 @@ public function fopen(string $path, string $mode) {
453454
}
454455
if ($this->file_exists($path)) {
455456
if (!$this->isUpdatable($path)) {
457+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', file not updatable.');
456458
return false;
457459
}
458460
$tmpFile = $this->getCachedFile($path);
459461
} else {
460462
if (!$this->isCreatable(dirname($path))) {
463+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', parent directory not writable.');
461464
return false;
462465
}
463466
$tmpFile = \OCP\Server::get(ITempManager::class)->getTemporaryFile($ext);
@@ -472,13 +475,16 @@ public function fopen(string $path, string $mode) {
472475
}
473476
return false;
474477
} catch (NotFoundException $e) {
478+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', not found.', ['exception' => $e]);
475479
return false;
476480
} catch (ForbiddenException $e) {
481+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', forbidden.', ['exception' => $e]);
477482
return false;
478483
} catch (OutOfSpaceException $e) {
484+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', out of space.', ['exception' => $e]);
479485
throw new EntityTooLargeException('not enough available space to create file', 0, $e);
480486
} catch (ConnectException $e) {
481-
$this->logger->error('Error while opening file', ['exception' => $e]);
487+
$this->logger->error('Error while opening file ' . $path . ' on ' . $this->getId(), ['exception' => $e]);
482488
throw new StorageNotAvailableException($e->getMessage(), (int)$e->getCode(), $e);
483489
}
484490
}

0 commit comments

Comments
 (0)