Skip to content

Commit 9460db7

Browse files
icewind1991backportbot[bot]
authored andcommitted
feat: improve logging of fopen failures for smb
Signed-off-by: Robin Appelman <[email protected]> [skip ci]
1 parent ce91153 commit 9460db7

File tree

1 file changed

+7
-1
lines changed
  • apps/files_external/lib/Lib/Storage

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private function getACL(IFileInfo $file): ?ACL {
211211
try {
212212
$acls = $file->getAcls();
213213
} catch (Exception $e) {
214-
$this->logger->error('Error while getting file acls', ['exception' => $e]);
214+
$this->logger->warning('Error while getting file acls', ['exception' => $e]);
215215
return null;
216216
}
217217
foreach ($acls as $user => $acl) {
@@ -462,6 +462,7 @@ public function fopen($path, $mode) {
462462
case 'r':
463463
case 'rb':
464464
if (!$this->file_exists($path)) {
465+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', file doesn\'t exist.');
465466
return false;
466467
}
467468
return $this->share->read($fullPath);
@@ -489,11 +490,13 @@ public function fopen($path, $mode) {
489490
}
490491
if ($this->file_exists($path)) {
491492
if (!$this->isUpdatable($path)) {
493+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', file not updatable.');
492494
return false;
493495
}
494496
$tmpFile = $this->getCachedFile($path);
495497
} else {
496498
if (!$this->isCreatable(dirname($path))) {
499+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', parent directory not writable.');
497500
return false;
498501
}
499502
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext);
@@ -508,10 +511,13 @@ public function fopen($path, $mode) {
508511
}
509512
return false;
510513
} catch (NotFoundException $e) {
514+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', not found.', ['exception' => $e]);
511515
return false;
512516
} catch (ForbiddenException $e) {
517+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', forbidden.', ['exception' => $e]);
513518
return false;
514519
} catch (OutOfSpaceException $e) {
520+
$this->logger->warning('Failed to open ' . $path . ' on ' . $this->getId() . ', out of space.', ['exception' => $e]);
515521
throw new EntityTooLargeException('not enough available space to create file', 0, $e);
516522
} catch (ConnectException $e) {
517523
$this->logger->error('Error while opening file', ['exception' => $e]);

0 commit comments

Comments
 (0)