Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialOwl committed Sep 29, 2021
1 parent 613253a commit f6b4629
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
24 changes: 18 additions & 6 deletions lib/Command/PointDownload.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
use ArtificialOwl\MySmallPhpTools\Exceptions\SignatureException;
use OC\Core\Command\Base;
use OCA\Backup\Db\PointRequest;
use OCA\Backup\Exceptions\RestoringChunkNotFoundException;
use OCA\Backup\Exceptions\RemoteInstanceException;
use OCA\Backup\Exceptions\RemoteInstanceNotFoundException;
use OCA\Backup\Exceptions\RemoteResourceNotFoundException;
use OCA\Backup\Exceptions\RestoringChunkNotFoundException;
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
use OCA\Backup\Model\RestoringChunkHealth;
use OCA\Backup\Model\RestoringHealth;
Expand All @@ -53,6 +53,7 @@
use OCP\Files\NotPermittedException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;


Expand Down Expand Up @@ -119,22 +120,24 @@ protected function configure() {
$this->setName('backup:point:download')
->setDescription('Download restoring point from remote instance')
->addArgument('instance', InputArgument::REQUIRED, 'address of the remote instance')
->addArgument('pointId', InputArgument::REQUIRED, 'Id of the restoring point');
->addArgument('pointId', InputArgument::REQUIRED, 'Id of the restoring point')
->addOption('no-check', '', InputOption::VALUE_NONE, 'do not check integrity of restoring point');
}


/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @throws NotFoundException
* @throws NotPermittedException
* @throws RemoteInstanceException
* @throws RemoteInstanceNotFoundException
* @throws RemoteResourceNotFoundException
* @throws RestoringChunkNotFoundException
* @throws RestoringPointNotFoundException
* @throws SignatoryException
* @throws SignatureException
* @throws NotFoundException
* @throws NotPermittedException
* @throws SignatoryException
*/
protected function execute(InputInterface $input, OutputInterface $output) {
$instance = $input->getArgument('instance');
Expand All @@ -147,7 +150,16 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$output->writeln('> downloading metadata');

$point = $this->remoteService->getRestoringPoint($instance, $pointId);
$this->remoteStreamService->verifyPoint($point);
if (!$input->getOption('no-check')) {
try {
$this->remoteStreamService->verifyPoint($point);
} catch (SignatureException $e) {
throw new SignatureException(
'Cannot confirm restoring point integrity.' . "\n"
. 'You can bypass this verification using --no-check'
);
}
}

$point->unsetHealth()
->setInstance('');
Expand Down
4 changes: 2 additions & 2 deletions lib/Command/RemoteAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ private function saveRemoteInstance(
$output->writeln('It is advised to export the setup of the Backup App in the file of your choice.');
$output->writeln('Keep in mind that with this file, any installation of Nextcloud can access your backup,');
$output->writeln('restore them and access the data of your users');
$output->writeln('While this is an option, ts is also advised to use a passphrase to encrypt the content of the file:');
$output->writeln('While this is an option, ts is also advised to force the creation of a key to encrypt the content of the file:');
$output->writeln('');
$output->writeln(' ./occ backup:setup:export [--passphrase your-passphrase] > ~/backup_setup.json');
$output->writeln(' ./occ backup:setup:export [--key] > ~/backup_setup.json');
$output->writeln('');
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Listeners/NodeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@


/**
* Class FileCreated
* Class NodeEvent
*
* @package OCA\Backup\Listeners
*/
Expand All @@ -61,7 +61,7 @@ class NodeEvent implements IEventListener {


/**
* FileCreated constructor.
* NodeEvent constructor.
*
* @param FilesService $filesService
*/
Expand Down
6 changes: 5 additions & 1 deletion lib/Service/ArchiveService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
use OCA\Backup\Exceptions\ArchiveNotFoundException;
use OCA\Backup\Exceptions\BackupAppCopyException;
use OCA\Backup\Exceptions\BackupScriptNotFoundException;
use OCA\Backup\Exceptions\RestoringChunkNotFoundException;
use OCA\Backup\Exceptions\EncryptionKeyException;
use OCA\Backup\Exceptions\RestoreChunkException;
use OCA\Backup\Exceptions\RestoringChunkNotFoundException;
use OCA\Backup\Exceptions\RestoringDataNotFoundException;
use OCA\Backup\Model\ArchiveFile;
use OCA\Backup\Model\Backup;
Expand Down Expand Up @@ -432,6 +432,10 @@ private function generateChunk(
$zipSize = 0;
while (($filename = array_shift($files)) !== null) {
$fileSize = filesize($data->getAbsolutePath() . $filename);
if (is_bool($fileSize)) {
$fileSize = 1;
}

if ($zipSize > 0 && ($zipSize + $fileSize) > self::MAX_ZIP_SIZE) {
$this->finalizeZip($zip, $chunk->setCount()->setSize($zipSize));
array_unshift($files, $filename);
Expand Down

0 comments on commit f6b4629

Please sign in to comment.