Skip to content

Commit

Permalink
admin settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialOwl committed Oct 1, 2021
1 parent 92289a4 commit 426a976
Show file tree
Hide file tree
Showing 19 changed files with 310 additions and 106 deletions.
11 changes: 6 additions & 5 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description><![CDATA[Backup today. Restore tomorrow.]]></description>
<licence>agpl</licence>
<author mail="maxence@artificial-owl.com">Maxence Lange</author>
<version>0.2.0</version>
<version>0.2.1</version>
<namespace>Backup</namespace>
<category>tools</category>
<website>https://github.com/nextcloud/backup</website>
Expand Down Expand Up @@ -43,10 +43,11 @@
<command>OCA\Backup\Command\SetupImport</command>

<command>OCA\Backup\Command\Reset</command>
</commands>

<settings>
<admin>OCA\Backup\Settings\Admin</admin>
<admin-section>OCA\Backup\Settings\AdminSection</admin-section>
</settings>

<!-- <command>OCA\Backup\Command\Listing</command>-->
<!-- <command>OCA\Backup\Command\Details</command>-->
<!-- <command>OCA\Backup\Command\Restore</command>-->
</commands>
</info>
16 changes: 8 additions & 8 deletions lib/Command/FileHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
use Exception;
use OC\Core\Command\Base;
use OCA\Backup\Exceptions\RestoringDataNotFoundException;
use OCA\Backup\Service\ArchiveService;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\PointService;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
Expand All @@ -58,21 +58,21 @@ class FileHistory extends Base {
/** @var PointService */
private $pointService;

/** @var ArchiveService */
private $archiveService;
/** @var ChunkService */
private $chunkService;


/**
* PointHistory constructor.
*
* @param PointService $pointService
* @param ArchiveService $archiveService
* @param ChunkService $chunkService
*/
public function __construct(PointService $pointService, ArchiveService $archiveService) {
public function __construct(PointService $pointService, ChunkService $chunkService) {
parent::__construct();

$this->pointService = $pointService;
$this->archiveService = $archiveService;
$this->chunkService = $chunkService;
}


Expand Down Expand Up @@ -119,11 +119,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
continue;
}

$data = $this->archiveService->getDataFromRP($point, $dataName);
$data = $this->chunkService->getDataFromRP($point, $dataName);

foreach ($data->getChunks() as $chunk) {
try {
$file = $this->archiveService->getArchiveFileFromChunk($point, $chunk, $filename);
$file = $this->chunkService->getArchiveFileFromChunk($point, $chunk, $filename);
$table->appendRow(
[
date('Y-m-d H:i:s', $point->getDate()),
Expand Down
8 changes: 4 additions & 4 deletions lib/Command/FileSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use OCA\Backup\Exceptions\ArchiveCreateException;
use OCA\Backup\Exceptions\ArchiveNotFoundException;
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
use OCA\Backup\Service\ArchiveService;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\PointService;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
Expand All @@ -64,17 +64,17 @@ class FileSearch extends Base {
/** @var PointService */
private $pointService;

/** @var ArchiveService */
/** @var ChunkService */
private $chunkService;


/**
* NodeSearch constructor.
*
* @param PointService $pointService
* @param ArchiveService $chunkService
* @param ChunkService $chunkService
*/
public function __construct(PointService $pointService, ArchiveService $chunkService) {
public function __construct(PointService $pointService, ChunkService $chunkService) {
parent::__construct();

$this->pointService = $pointService;
Expand Down
8 changes: 4 additions & 4 deletions lib/Command/PointDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
use OCA\Backup\Exceptions\RemoteResourceNotFoundException;
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
use OCA\Backup\Model\RestoringData;
use OCA\Backup\Service\ArchiveService;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\PointService;
use OCA\Backup\Service\RemoteService;
use OCP\Files\NotFoundException;
Expand Down Expand Up @@ -71,7 +71,7 @@ class PointDetails extends Base {
/** @var PointService */
private $pointService;

/** @var ArchiveService */
/** @var ChunkService */
private $chunkService;


Expand All @@ -80,12 +80,12 @@ class PointDetails extends Base {
*
* @param RemoteService $remoteService
* @param PointService $pointService
* @param ArchiveService $chunkService
* @param ChunkService $chunkService
*/
public function __construct(
RemoteService $remoteService,
PointService $pointService,
ArchiveService $chunkService
ChunkService $chunkService
) {
parent::__construct();

Expand Down
8 changes: 4 additions & 4 deletions lib/Command/PointDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
use OCA\Backup\Model\RestoringChunkHealth;
use OCA\Backup\Model\RestoringHealth;
use OCA\Backup\Model\RestoringPoint;
use OCA\Backup\Service\ArchiveService;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\OutputService;
use OCA\Backup\Service\PointService;
use OCA\Backup\Service\RemoteService;
Expand All @@ -71,7 +71,7 @@ class PointDownload extends Base {
/** @var PointService */
private $pointService;

/** @var ArchiveService */
/** @var ChunkService */
private $chunkService;

/** @var RemoteStreamService */
Expand All @@ -89,15 +89,15 @@ class PointDownload extends Base {
*
* @param PointRequest $pointRequest
* @param PointService $pointService
* @param ArchiveService $chunkService
* @param ChunkService $chunkService
* @param RemoteStreamService $remoteStreamService
* @param RemoteService $remoteService
* @param OutputService $outputService
*/
public function __construct(
PointRequest $pointRequest,
PointService $pointService,
ArchiveService $chunkService,
ChunkService $chunkService,
RemoteStreamService $remoteStreamService,
RemoteService $remoteService,
OutputService $outputService
Expand Down
12 changes: 6 additions & 6 deletions lib/Command/PointHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


use OC\Core\Command\Base;
use OCA\Backup\Service\ArchiveService;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\PointService;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -50,21 +50,21 @@ class PointHistory extends Base {
/** @var PointService */
private $pointService;

/** @var ArchiveService */
private $archiveService;
/** @var ChunkService */
private $chunkService;


/**
* PointHistory constructor.
*
* @param PointService $pointService
* @param ArchiveService $archiveService
* @param ChunkService $chunkService
*/
public function __construct(PointService $pointService, ArchiveService $archiveService) {
public function __construct(PointService $pointService, ChunkService $chunkService) {
parent::__construct();

$this->pointService = $pointService;
$this->archiveService = $archiveService;
$this->chunkService = $chunkService;
}


Expand Down
2 changes: 0 additions & 2 deletions lib/Command/PointList.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
);
}

// echo 'RP: ' . json_encode($rp, JSON_PRETTY_PRINT);

return 0;
}

Expand Down
30 changes: 15 additions & 15 deletions lib/Command/PointRestore.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
use OCA\Backup\Model\RestoringData;
use OCA\Backup\Model\RestoringHealth;
use OCA\Backup\Model\RestoringPoint;
use OCA\Backup\Service\ArchiveService;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\ConfigService;
use OCA\Backup\Service\FilesService;
use OCA\Backup\Service\OutputService;
Expand Down Expand Up @@ -80,8 +80,8 @@ class PointRestore extends Base {
/** @var PointService */
private $pointService;

/** @var ArchiveService */
private $archiveService;
/** @var ChunkService */
private $chunkService;

/** @var FilesService */
private $filesService;
Expand All @@ -107,15 +107,15 @@ class PointRestore extends Base {
* PointRestore constructor.
*
* @param PointService $pointService
* @param ArchiveService $archiveService
* @param ChunkService $chunkService
* @param FilesService $filesService
* @param RestoreService $restoreService
* @param ConfigService $configService
* @param OutputService $outputService
*/
public function __construct(
PointService $pointService,
ArchiveService $archiveService,
ChunkService $chunkService,
FilesService $filesService,
RestoreService $restoreService,
ConfigService $configService,
Expand All @@ -124,7 +124,7 @@ public function __construct(
parent::__construct();

$this->pointService = $pointService;
$this->archiveService = $archiveService;
$this->chunkService = $chunkService;
$this->filesService = $filesService;
$this->restoreService = $restoreService;
$this->configService = $configService;
Expand Down Expand Up @@ -267,7 +267,7 @@ public function restorePointComplete(RestoringPoint $point): void {
);

try {
$this->archiveService->restoreChunk($point, $chunk, $root);
$this->chunkService->restoreChunk($point, $chunk, $root);
$this->output->writeln('<info>ok</info>');
} catch (
ArchiveCreateException
Expand Down Expand Up @@ -299,7 +299,7 @@ private function importSqlDump(RestoringPoint $point, RestoringData $data): void

$chunk = $chunks[0];
try {
$read = $this->archiveService->getStreamFromChunk(
$read = $this->chunkService->getStreamFromChunk(
$point,
$chunk,
PointService::SQL_DUMP_FILE
Expand Down Expand Up @@ -349,16 +349,16 @@ private function restoreUniqueFile(
$this->pointService->initBaseFolder($point);
if (!is_null($chunkName)) {
if (is_null($dataName)) {
$data = $this->archiveService->getDataWithChunk($point, $chunkName);
$data = $this->chunkService->getDataWithChunk($point, $chunkName);
} else {
$data = $this->archiveService->getDataFromRP($point, $dataName);
$data = $this->chunkService->getDataFromRP($point, $dataName);
}

$chunk = $this->archiveService->getChunkFromRP($point, $chunkName, $data->getName());
$file = $this->archiveService->getArchiveFileFromChunk($point, $chunk, $filename);
$chunk = $this->chunkService->getChunkFromRP($point, $chunkName, $data->getName());
$file = $this->chunkService->getArchiveFileFromChunk($point, $chunk, $filename);
} else {
$data = $this->archiveService->getDataFromRP($point, $dataName);
$file = $this->archiveService->getArchiveFileFromData($point, $data, $filename);
$data = $this->chunkService->getDataFromRP($point, $dataName);
$file = $this->chunkService->getArchiveFileFromData($point, $data, $filename);
}

$root = $data->getAbsolutePath();
Expand All @@ -372,7 +372,7 @@ private function restoreUniqueFile(
// TODO: display $root and add a confirmation step

try {
$this->archiveService->restoreUniqueFile($point, $chunk, $root, $file->getName());
$this->chunkService->restoreUniqueFile($point, $chunk, $root, $file->getName());
$this->output->writeln('<info>ok</info>');

// include restored file in next incremental backup
Expand Down
12 changes: 6 additions & 6 deletions lib/Command/PointScan.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use OCA\Backup\Db\PointRequest;
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
use OCA\Backup\Model\RestoringPoint;
use OCA\Backup\Service\ArchiveService;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\OutputService;
use OCA\Backup\Service\PointService;
use OCP\Files\NotFoundException;
Expand All @@ -64,8 +64,8 @@ class PointScan extends Base {
/** @var PointService */
private $pointService;

/** @var ArchiveService */
private $archiveService;
/** @var ChunkService */
private $chunkService;

/** @var OutputService */
private $outputService;
Expand All @@ -83,17 +83,17 @@ class PointScan extends Base {
*
* @param PointRequest $pointRequest
* @param PointService $pointService
* @param ArchiveService $archiveService
* @param ChunkService $chunkService
*/
public function __construct(
PointRequest $pointRequest,
PointService $pointService,
ArchiveService $archiveService
ChunkService $chunkService
) {
parent::__construct();

$this->pointRequest = $pointRequest;
$this->archiveService = $archiveService;
$this->chunkService = $chunkService;
$this->pointService = $pointService;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Model/RestoringChunkPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* later. See the COPYING file.
*
* @author Maxence Lange <maxence@artificial-owl.com>
* @copyright 2019, Maxence Lange <maxence@artificial-owl.com>
* @copyright 2021, Maxence Lange <maxence@artificial-owl.com>
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
Expand Down
8 changes: 4 additions & 4 deletions lib/RemoteRequest/DownloadRestoringChunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
use OCA\Backup\IRemoteRequest;
use OCA\Backup\Model\RestoringChunk;
use OCA\Backup\Service\ArchiveService;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\PointService;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
Expand All @@ -61,19 +61,19 @@ class DownloadRestoringChunk extends CoreRequest implements IRemoteRequest {
/** @var PointService */
private $pointService;

/** @var ArchiveService */
/** @var ChunkService */
private $chunkService;


/**
* DownloadRestoringChunk constructor.
*
* @param PointService $pointService
* @param ArchiveService $chunkService
* @param ChunkService $chunkService
*/
public function __construct(
PointService $pointService,
ArchiveService $chunkService
ChunkService $chunkService
) {
parent::__construct();

Expand Down

0 comments on commit 426a976

Please sign in to comment.