summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-11-25 09:28:38 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2020-11-25 10:40:21 +0000
commit2ff42f6b1acc9be8b18e0f0fd8dd2b47d536d19f (patch)
treee16a5936cb4204e41836f9fee8d787b56eec78b2 /apps
parent940e8c3a99e5a9f0cbb1dbc3f32e6cb9a693d52d (diff)
downloadnextcloud-server-2ff42f6b1acc9be8b18e0f0fd8dd2b47d536d19f.tar.gz
nextcloud-server-2ff42f6b1acc9be8b18e0f0fd8dd2b47d536d19f.zip
Catch storage not available in versions expire command
External storage with session credentials is not accessible without a user session, hence background jobs and CLI commands can't work with them. The previously unhandled exception causes logged errors in the nextcloud log. This patch catches the specific exception and logs it as warnings. So for a production instance the error won't spam their logs for this non-recoverable and technically unsolvable error if the minimum log level is set to the default of 3 (error). Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_versions/lib/Command/Expire.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/files_versions/lib/Command/Expire.php b/apps/files_versions/lib/Command/Expire.php
index 1075314c1c4..bf3400b5018 100644
--- a/apps/files_versions/lib/Command/Expire.php
+++ b/apps/files_versions/lib/Command/Expire.php
@@ -28,6 +28,8 @@ namespace OCA\Files_Versions\Command;
use OC\Command\FileAccess;
use OCA\Files_Versions\Storage;
use OCP\Command\ICommand;
+use OCP\Files\StorageNotAvailableException;
+use OCP\ILogger;
class Expire implements ICommand {
use FileAccess;
@@ -59,6 +61,20 @@ class Expire implements ICommand {
return;
}
- Storage::expire($this->fileName, $this->user);
+ try {
+ Storage::expire($this->fileName, $this->user);
+ } catch (StorageNotAvailableException $e) {
+ // In case of external storage and session credentials, the expiration
+ // fails because the command does not have those credentials
+
+ /** @var ILogger $logger */
+ $logger = \OC::$server->get(ILogger::class);
+
+ $logger->logException($e, [
+ 'level' => ILogger::WARN,
+ 'uid' => $this->user,
+ 'fileName' => $this->fileName,
+ ]);
+ }
}
}