Merge pull request #24367 from nextcloud/backport/24363/stable20

[stable20] Catch storage not available in versions expire command
This commit is contained in:
Roeland Jago Douma 2020-11-25 16:17:34 +01:00 committed by GitHub
commit ae9fd3e225
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -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,
]);
}
}
}