Avoid showing "Memories: Indexing process stopped before completion. Will continue on next run" as a warning

An indexing cron job not finishing is just normal operation, so
we shouldn't emit a warning for it. This commit emits a info
instead when this happens.

While we are at it, we also emit a info message if the indexing
was successful.
pull/606/head
Leandro Lucarella 2023-04-23 11:53:38 +02:00 committed by GitHub
parent b0878e8e49
commit 94e9b616d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -63,7 +63,7 @@ class IndexJob extends TimedJob
$this->indexAllUsers(); $this->indexAllUsers();
$this->log('Indexing completed successfully', 'success'); $this->log('Indexing completed successfully', 'success');
} catch (Service\ProcessClosedException $e) { } catch (Service\ProcessClosedException $e) {
$this->log('Indexing process stopped before completion. Will continue on next run', 'warning'); $this->log('Indexing process stopped before completion. Will continue on next run', 'info');
} finally { } finally {
\OCA\Memories\Exif::closeStaticExiftoolProc(); \OCA\Memories\Exif::closeStaticExiftoolProc();
} }
@ -95,6 +95,11 @@ class IndexJob extends TimedJob
private function log(string $msg, string $type = 'error'): void private function log(string $msg, string $type = 'error'): void
{ {
if ('success' === $type || 'info' === $type) {
// If this is just an informational message, we log it with level info
$this->logger->info('Memories: '.$msg);
}
if ($this->_hasError && 'success' === $type) { if ($this->_hasError && 'success' === $type) {
// Don't overwrite an error with a success // Don't overwrite an error with a success
return; return;
@ -103,9 +108,7 @@ class IndexJob extends TimedJob
$this->config->setAppValue(Application::APPNAME, 'last_index_job_status', $msg); $this->config->setAppValue(Application::APPNAME, 'last_index_job_status', $msg);
$this->config->setAppValue(Application::APPNAME, 'last_index_job_status_type', $type); $this->config->setAppValue(Application::APPNAME, 'last_index_job_status_type', $type);
if ('success' === $type) { if ('warning' === $type) {
// Nothing
} elseif ('warning' === $type) {
$this->logger->warning('Memories: '.$msg); $this->logger->warning('Memories: '.$msg);
} elseif ('error' === $type) { } elseif ('error' === $type) {
$this->_hasError = true; $this->_hasError = true;