Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Nov 19, 2021
1 parent 557eba4 commit 022f2b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/Command/PointList.php
Expand Up @@ -35,6 +35,7 @@
use ArtificialOwl\MySmallPhpTools\Exceptions\SignatureException;
use ArtificialOwl\MySmallPhpTools\Traits\TStringTools;
use OC\Core\Command\Base;
use OCA\Backup\Model\RemoteInstance;
use OCA\Backup\Model\RestoringData;
use OCA\Backup\Model\RestoringHealth;
use OCA\Backup\Model\RestoringPoint;
Expand Down Expand Up @@ -171,7 +172,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
($fresh) ? $point->getParent() : '',
$comment,
implode(',', $status),
$instance,
($instance === RemoteInstance::LOCAL) ? '<info>' . $instance . '</info>' : $instance,
$this->displayStyleHealth($point),
'<error>' . $issue . '</error>'
]
Expand Down
12 changes: 10 additions & 2 deletions lib/Cron/Backup.php
Expand Up @@ -36,6 +36,7 @@
use OCA\Backup\Service\ConfigService;
use OCA\Backup\Service\CronService;
use OCA\Backup\Service\PointService;
use Psr\Log\LoggerInterface;
use Throwable;

/**
Expand All @@ -56,31 +57,36 @@ class Backup extends TimedJob {
/** @var ConfigService */
private $configService;

/** @var LoggerInterface */
private $loggerInterface;

/**
* Backup constructor.
*
* @param PointService $pointService
* @param CronService $cronService
* @param ConfigService $configService
* @param LoggerInterface $loggerInterface
*/
public function __construct(
PointService $pointService,
CronService $cronService,
ConfigService $configService
ConfigService $configService,
LoggerInterface $loggerInterface
) {
$this->setInterval(900);

$this->pointService = $pointService;
$this->cronService = $cronService;
$this->configService = $configService;
$this->loggerInterface = $loggerInterface;
}


/**
* @param $argument
*/
protected function run($argument):void {
protected function run($argument): void {
if (!$this->cronService->isRealCron()) {
return;
}
Expand Down Expand Up @@ -115,6 +121,7 @@ private function runFullBackup(): void {
try {
$this->pointService->create(true);
} catch (Throwable $e) {
$this->loggerInterface->debug('error while running full backup - ' . json_encode(debug_backtrace()));
}
}

Expand All @@ -126,6 +133,7 @@ private function runDifferentialBackup(): void {
try {
$this->pointService->create(false);
} catch (Throwable $e) {
$this->loggerInterface->error('error while running differential backup - ' . json_encode(debug_backtrace()));
}
}
}
4 changes: 3 additions & 1 deletion lib/Cron/Manage.php
Expand Up @@ -49,6 +49,8 @@
class Manage extends TimedJob {


const DELAY_CHECK_HEALTH = 86400 * 7; // 7d

/** @var CronService */
private $cronService;

Expand Down Expand Up @@ -141,7 +143,7 @@ protected function run($argument) {
// regenerate local health
foreach ($this->pointService->getLocalRestoringPoints() as $point) {
if ($point->hasHealth()
&& $point->getHealth()->getChecked() > time() - 3600 * 12) {
&& $point->getHealth()->getChecked() > time() - self::DELAY_CHECK_HEALTH) {
continue;
}
try {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/FilesService.php
Expand Up @@ -107,7 +107,7 @@ public function fillRestoringData(RestoringData $data, string $path): void {
if (!is_dir($data->getAbsolutePath() . rtrim($path, '/'))) {
if ($data->getType() === RestoringData::ROOT_DATA
&& !$this->configService->getAppValueBool(ConfigService::INCLUDE_LOGS)
&& $path === 'nextcloud.log') {
&& substr($path, 0, 13) === 'nextcloud.log') {
return;
}

Expand Down

0 comments on commit 022f2b3

Please sign in to comment.