Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable20] Catch storage not available in versions expire command #24367

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion apps/files_versions/lib/Command/Expire.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
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;
Expand Down Expand Up @@ -59,6 +61,20 @@ public function handle() {
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,
]);
}
}
}