Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added logging to Notify command.
Signed-off-by: Ari Selseng <[email protected]>
  • Loading branch information
ariselseng authored and Backportbot committed Apr 8, 2019
commit 793b02a27da979a2e507e45c78533c715dc02490
11 changes: 9 additions & 2 deletions apps/files_external/lib/Command/Notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\IDBConnection;
use OCP\ILogger;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -49,11 +50,14 @@ class Notify extends Base {
private $connection;
/** @var \OCP\DB\QueryBuilder\IQueryBuilder */
private $updateQuery;
/** @var ILogger */
private $log;

function __construct(GlobalStoragesService $globalService, IDBConnection $connection) {
function __construct(GlobalStoragesService $globalService, IDBConnection $connection, ILogger $logger) {
parent::__construct();
$this->globalService = $globalService;
$this->connection = $connection;
$this->logger = $logger;
$this->updateQuery = $this->getUpdateQuery($this->connection);
}

Expand Down Expand Up @@ -159,7 +163,8 @@ private function markParentAsOutdated($mountId, $path, OutputInterface $output)

try {
$this->updateQuery->execute([$parent, $mountId]);
} catch (DriverException $th) {
} catch (DriverException $ex) {
$this->logger->logException($ex, ['app' => 'files_external', 'message' => 'Error while trying to mark folder as outdated', 'level' => ILogger::WARN]);
$this->connection = $this->reconnectToDatabase($this->connection, $output);
$output->writeln('<info>Needed to reconnect to the database</info>');
$this->updateQuery = $this->getUpdateQuery($this->connection);
Expand Down Expand Up @@ -212,12 +217,14 @@ private function reconnectToDatabase(IDBConnection $connection, OutputInterface
try {
$connection->close();
} catch (\Exception $ex) {
$this->logger->logException($ex, ['app' => 'files_external', 'message' => 'Error while disconnecting from DB', 'level' => ILogger::WARN]);
$output->writeln("<info>Error while disconnecting from database: {$ex->getMessage()}</info>");
}
while (!$connection->isConnected()) {
try {
$connection->connect();
} catch (\Exception $ex) {
$this->logger->logException($ex, ['app' => 'files_external', 'message' => 'Error while re-connecting to database', 'level' => ILogger::WARN]);
$output->writeln("<info>Error while re-connecting to database: {$ex->getMessage()}</info>");
sleep(60);
}
Expand Down