Skip to content

Commit a9d25e8

Browse files
committed
status on details
1 parent 80cb94a commit a9d25e8

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

lib/Command/PointDetails.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use OCA\Backup\Exceptions\RestoringPointException;
4545
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
4646
use OCA\Backup\Exceptions\RestoringPointPackException;
47+
use OCA\Backup\Model\ChunkPartHealth;
4748
use OCA\Backup\Model\RestoringChunk;
4849
use OCA\Backup\Model\RestoringData;
4950
use OCA\Backup\Model\RestoringPoint;
@@ -171,7 +172,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
171172
return 0;
172173
}
173174

174-
echo json_encode($point);
175175
$output = new ConsoleOutput();
176176
$output = $output->section();
177177

@@ -195,7 +195,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
195195
$table = new Table($output);
196196
$table->setHeaders(['Chunk Id', 'Size', 'Count', 'Part Id', 'Checksum', 'verified']);
197197
$table->render();
198-
echo '-';
198+
199199
foreach ($data->getChunks() as $chunk) {
200200
if ($point->isStatus(RestoringPoint::STATUS_PACKED)) {
201201
$this->displayDetailsPacked($table, $point, $chunk);
@@ -239,15 +239,19 @@ private function displayDetailsPacked(
239239
RestoringChunk $chunk
240240
): void {
241241
$fresh = true;
242+
$health = $point->getHealth();
242243
foreach ($chunk->getParts() as $part) {
243-
try {
244-
$checked = $this->packService->getChecksum($point, $chunk, $part);
245-
} catch (ArchiveNotFoundException $e) {
246-
$checked = '<error>missing chunk</error>';
247-
}
248-
249-
$color = ($checked === $part->getCurrentChecksum()) ? 'info' : 'error';
250-
$checked = '<' . $color . '>' . $checked . '</' . $color . '>';
244+
$partHealth = $health->getPart($chunk->getName(), $part->getName());
245+
$status = ChunkPartHealth::$DEF_STATUS[$partHealth->getStatus()];
246+
//
247+
// try {
248+
// $checked = $this->packService->getChecksum($point, $chunk, $part);
249+
// } catch (ArchiveNotFoundException $e) {
250+
// $checked = '<error>missing chunk</error>';
251+
// }
252+
253+
$color = ($partHealth->getStatus() === ChunkPartHealth::STATUS_OK) ? 'info' : 'error';
254+
$status = '<' . $color . '>' . $status . '</' . $color . '>';
251255

252256
$table->appendRow(
253257
[
@@ -256,7 +260,7 @@ private function displayDetailsPacked(
256260
($fresh) ? $chunk->getCount() : '',
257261
$part->getName(),
258262
$part->getCurrentChecksum(),
259-
$checked
263+
$status
260264
]
261265
);
262266

lib/Model/ChunkPartHealth.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ class ChunkPartHealth implements IDeserializable, JsonSerializable {
5454
const STATUS_CHECKSUM = 3;
5555

5656

57+
public static $DEF_STATUS = [
58+
self::STATUS_UNKNOWN => 'unknown',
59+
self::STATUS_OK => 'ok',
60+
self::STATUS_MISSING => 'missing',
61+
self::STATUS_CHECKSUM => 'checksum'
62+
];
63+
5764
/** @var bool */
5865
private $packed;
5966

0 commit comments

Comments
 (0)