Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/backup.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2021-11-20 21:56:04 +0300
committerMaxence Lange <maxence@artificial-owl.com>2021-11-20 21:56:04 +0300
commit1c142662f2e4a38cd6082b2588657a9747149ddb (patch)
tree5a16b51a9aeeb349166f5fd026132d431c19a5af
parentb7c48305b1213d2e84841d5be47cffb8326461b9 (diff)
chunk part health check during upload/downloadenh/70/upload-chunk-part-check
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rwxr-xr-xlib/Command/PointDownload.php19
-rw-r--r--lib/Service/UploadService.php49
2 files changed, 33 insertions, 35 deletions
diff --git a/lib/Command/PointDownload.php b/lib/Command/PointDownload.php
index dbba2e4..076cc57 100755
--- a/lib/Command/PointDownload.php
+++ b/lib/Command/PointDownload.php
@@ -50,6 +50,7 @@ use OCA\Backup\Model\RestoringPoint;
use OCA\Backup\Service\ChunkService;
use OCA\Backup\Service\ConfigService;
use OCA\Backup\Service\ExternalFolderService;
+use OCA\Backup\Service\MetadataService;
use OCA\Backup\Service\OutputService;
use OCA\Backup\Service\PackService;
use OCA\Backup\Service\PointService;
@@ -91,6 +92,9 @@ class PointDownload extends Base {
/** @var RemoteService */
private $remoteService;
+ /** @var MetadataService */
+ private $metadataService;
+
/** @var ExternalFolderService */
private $externalFolderService;
@@ -110,6 +114,7 @@ class PointDownload extends Base {
* @param PackService $packService
* @param RemoteStreamService $remoteStreamService
* @param RemoteService $remoteService
+ * @param MetadataService $metadataService
* @param ExternalFolderService $externalFolderService
* @param OutputService $outputService
* @param ConfigService $configService
@@ -121,6 +126,7 @@ class PointDownload extends Base {
PackService $packService,
RemoteStreamService $remoteStreamService,
RemoteService $remoteService,
+ MetadataService $metadataService,
ExternalFolderService $externalFolderService,
OutputService $outputService,
ConfigService $configService
@@ -133,6 +139,7 @@ class PointDownload extends Base {
$this->packService = $packService;
$this->remoteStreamService = $remoteStreamService;
$this->remoteService = $remoteService;
+ $this->metadataService = $metadataService;
$this->externalFolderService = $externalFolderService;
$this->outputService = $outputService;
$this->configService = $configService;
@@ -287,6 +294,7 @@ class PointDownload extends Base {
* @throws RestoringPointNotFoundException
* @throws RestoringPointNotInitiatedException
* @throws LockedException
+ * @throws NotFoundException
*/
private function downloadMissingFiles(
OutputInterface $output,
@@ -305,6 +313,7 @@ class PointDownload extends Base {
'/' . $partHealth->getChunkName() . '/' . $partHealth->getPartName() . ': '
);
+ $data = $this->chunkService->getDataFromRP($point, $partHealth->getDataName());
$chunk = $this->chunkService->getChunkFromRP(
$point,
$partHealth->getChunkName(),
@@ -324,15 +333,13 @@ class PointDownload extends Base {
$part
);
} else {
- $msg = 'use --external';
- if ($this->configService->isRemoteEnabled()) {
- $msg = 'use --remote or --external';
- }
- throw new InvalidOptionException($msg);
+ throw new InvalidOptionException('use --external');
}
-// $chunk = $this->remoteService->downloadChunk($instance, $point, $restoringChunk);
$this->packService->saveChunkPartContent($point, $chunk, $part);
+ $this->pointService->generateHealthChunk($health, $point, $data, $chunk);
+
+ $this->pointService->storeHealth($point);
$output->writeln('<info>ok</info>');
}
}
diff --git a/lib/Service/UploadService.php b/lib/Service/UploadService.php
index 87dd03e..b937d4b 100644
--- a/lib/Service/UploadService.php
+++ b/lib/Service/UploadService.php
@@ -193,7 +193,7 @@ class UploadService {
}
$health = $stored->getHealth();
- $this->o(' > Health status: ' . $this->outputService->displayHealth($health));
+ $this->o(' > Health status: ' . $this->outputService->displayHealth($stored));
if ($health->getStatus() === RestoringHealth::STATUS_OK) {
continue;
}
@@ -227,7 +227,7 @@ class UploadService {
if ($partHealth->getStatus() === ChunkPartHealth::STATUS_OK) {
continue;
}
-
+
if ($partHealth->getChunkName() === $partHealth->getPartName()) {
$this->o(
' * Uploading <info>' . $partHealth->getDataName() . '</info>/<info>'
@@ -290,36 +290,14 @@ class UploadService {
);
$stored = $this->externalFolderService->confirmPoint($external, $point);
-
- // TODO: get fresh health
- if (!$stored->hasHealth()) {
- $this->o('no health status available');
- continue;
- }
-
$health = $stored->getHealth();
-// } else {
-// try {
-// $this->o(' > <comment>no health status attached</comment>');
-// $this->o(' * Requesting detailed Health status: ', false);
-// try {
-// $health = $this->externalFolderService->getCurrentHealth($external, $point);
-// $this->o('<info>ok</info>');
-// } catch (Exception $e) {
-// $this->o('<error>' . $e->getMessage() . '</error>');
-// continue;
-// }
-// } catch (Exception $e) {
-// continue;
-// }
-// }
-
- $this->o(' > Health status: ' . $this->outputService->displayHealth($health));
+
+ $this->o(' > Health status: ' . $this->outputService->displayHealth($stored));
if ($health->getStatus() === RestoringHealth::STATUS_OK) {
continue;
}
- $this->uploadMissingFilesToExternalFolder($external, $point, $health);
+ $this->uploadMissingFilesToExternalFolder($external, $stored);
$this->externalFolderService->getRestoringPoint($external, $point->getId());
} catch (RestoringChunkPartNotFoundException $e) {
try {
@@ -350,9 +328,9 @@ class UploadService {
*/
private function uploadMissingFilesToExternalFolder(
ExternalFolder $external,
- RestoringPoint $point,
- RestoringHealth $health
+ RestoringPoint $point
): void {
+ $health = $point->getHealth();
$this->pointService->initBaseFolder($point);
foreach ($health->getParts() as $partHealth) {
if ($partHealth->getStatus() === ChunkPartHealth::STATUS_OK) {
@@ -384,6 +362,19 @@ class UploadService {
$this->packService->getChunkPartContent($point, $chunk, $part);
$this->externalFolderService->uploadPart($external, $point, $health, $chunk, $part);
+
+ $data = $this->chunkService->getDataFromRP($point, $partHealth->getDataName());
+
+ $this->externalFolderService->generateHealthPart(
+ $external,
+ $health,
+ $point,
+ $data,
+ $chunk,
+ $part
+ );
+ $this->externalFolderService->updateMetadataFile($external, $point);
+
$this->o('<info>ok</info>');
} catch (
RestoringChunkNotFoundException |