Skip to content

Commit

Permalink
status on details
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialOwl committed Oct 12, 2021
1 parent 80cb94a commit a9d25e8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/Command/PointDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use OCA\Backup\Exceptions\RestoringPointException;
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
use OCA\Backup\Exceptions\RestoringPointPackException;
use OCA\Backup\Model\ChunkPartHealth;
use OCA\Backup\Model\RestoringChunk;
use OCA\Backup\Model\RestoringData;
use OCA\Backup\Model\RestoringPoint;
Expand Down Expand Up @@ -171,7 +172,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

echo json_encode($point);
$output = new ConsoleOutput();
$output = $output->section();

Expand All @@ -195,7 +195,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$table = new Table($output);
$table->setHeaders(['Chunk Id', 'Size', 'Count', 'Part Id', 'Checksum', 'verified']);
$table->render();
echo '-';

foreach ($data->getChunks() as $chunk) {
if ($point->isStatus(RestoringPoint::STATUS_PACKED)) {
$this->displayDetailsPacked($table, $point, $chunk);
Expand Down Expand Up @@ -239,15 +239,19 @@ private function displayDetailsPacked(
RestoringChunk $chunk
): void {
$fresh = true;
$health = $point->getHealth();
foreach ($chunk->getParts() as $part) {
try {
$checked = $this->packService->getChecksum($point, $chunk, $part);
} catch (ArchiveNotFoundException $e) {
$checked = '<error>missing chunk</error>';
}

$color = ($checked === $part->getCurrentChecksum()) ? 'info' : 'error';
$checked = '<' . $color . '>' . $checked . '</' . $color . '>';
$partHealth = $health->getPart($chunk->getName(), $part->getName());
$status = ChunkPartHealth::$DEF_STATUS[$partHealth->getStatus()];
//
// try {
// $checked = $this->packService->getChecksum($point, $chunk, $part);
// } catch (ArchiveNotFoundException $e) {
// $checked = '<error>missing chunk</error>';
// }

$color = ($partHealth->getStatus() === ChunkPartHealth::STATUS_OK) ? 'info' : 'error';
$status = '<' . $color . '>' . $status . '</' . $color . '>';

$table->appendRow(
[
Expand All @@ -256,7 +260,7 @@ private function displayDetailsPacked(
($fresh) ? $chunk->getCount() : '',
$part->getName(),
$part->getCurrentChecksum(),
$checked
$status
]
);

Expand Down
7 changes: 7 additions & 0 deletions lib/Model/ChunkPartHealth.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class ChunkPartHealth implements IDeserializable, JsonSerializable {
const STATUS_CHECKSUM = 3;


public static $DEF_STATUS = [
self::STATUS_UNKNOWN => 'unknown',
self::STATUS_OK => 'ok',
self::STATUS_MISSING => 'missing',
self::STATUS_CHECKSUM => 'checksum'
];

/** @var bool */
private $packed;

Expand Down

0 comments on commit a9d25e8

Please sign in to comment.