Skip to content

Commit b37170b

Browse files
Merge pull request #53612 from nextcloud/backport/53426/stable31
[stable31] feat: improve logging of fopen failures for smb
2 parents 92249b5 + 6cece4f commit b37170b

File tree

1 file changed

+8
-2
lines changed
  • apps/files_external/lib/Lib/Storage

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private function getACL(IFileInfo $file): ?ACL {
196196
try {
197197
$acls = $file->getAcls();
198198
} catch (Exception $e) {
199-
$this->logger->error('Error while getting file acls', ['exception' => $e]);
199+
$this->logger->warning('Error while getting file acls', ['exception' => $e]);
200200
return null;
201201
}
202202
foreach ($acls as $user => $acl) {
@@ -424,6 +424,7 @@ public function fopen(string $path, string $mode) {
424424
case 'r':
425425
case 'rb':
426426
if (!$this->file_exists($path)) {
427+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', file doesn\'t exist.');
427428
return false;
428429
}
429430
return $this->share->read($fullPath);
@@ -451,11 +452,13 @@ public function fopen(string $path, string $mode) {
451452
}
452453
if ($this->file_exists($path)) {
453454
if (!$this->isUpdatable($path)) {
455+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', file not updatable.');
454456
return false;
455457
}
456458
$tmpFile = $this->getCachedFile($path);
457459
} else {
458460
if (!$this->isCreatable(dirname($path))) {
461+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', parent directory not writable.');
459462
return false;
460463
}
461464
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
@@ -470,13 +473,16 @@ public function fopen(string $path, string $mode) {
470473
}
471474
return false;
472475
} catch (NotFoundException $e) {
476+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', not found.', ['exception' => $e]);
473477
return false;
474478
} catch (ForbiddenException $e) {
479+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', forbidden.', ['exception' => $e]);
475480
return false;
476481
} catch (OutOfSpaceException $e) {
482+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', out of space.', ['exception' => $e]);
477483
throw new EntityTooLargeException('not enough available space to create file', 0, $e);
478484
} catch (ConnectException $e) {
479-
$this->logger->error('Error while opening file', ['exception' => $e]);
485+
$this->logger->error('Error while opening file ' . $path . ' on ' . $this->getId(), ['exception' => $e]);
480486
throw new StorageNotAvailableException($e->getMessage(), (int)$e->getCode(), $e);
481487
}
482488
}

0 commit comments

Comments
 (0)