Skip to content

Commit e39c06c

Browse files
committed
upload on single location
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
1 parent fae7dc4 commit e39c06c

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

lib/Command/PointUpload.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
use OCP\Files\NotPermittedException;
4646
use Symfony\Component\Console\Input\InputArgument;
4747
use Symfony\Component\Console\Input\InputInterface;
48+
use Symfony\Component\Console\Input\InputOption;
4849
use Symfony\Component\Console\Output\OutputInterface;
4950

5051
/**
@@ -97,7 +98,9 @@ public function __construct(
9798
protected function configure() {
9899
$this->setName('backup:point:upload')
99100
->setDescription('Upload a local restoring point on others instances')
100-
->addArgument('point', InputArgument::REQUIRED, 'Id of the restoring point');
101+
->addArgument('point', InputArgument::REQUIRED, 'Id of the restoring point')
102+
->addOption('remote', '', InputOption::VALUE_REQUIRED, 'address of the remote instance', '')
103+
->addOption('external', '', InputOption::VALUE_REQUIRED, 'id of the external folder', '');
101104
}
102105

103106

@@ -118,6 +121,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
118121
$point = $this->pointService->getLocalRestoringPoint($input->getArgument('point'));
119122

120123
$this->outputService->setOutput($output);
124+
if ($input->getOption('external')) {
125+
$this->uploadService->initUpload($point);
126+
$this->uploadService->uploadToExternalFolder($point, (int)$input->getOption('external'));
127+
128+
return 0;
129+
}
130+
131+
if ($input->getOption('remote')) {
132+
$this->uploadService->initUpload($point);
133+
$this->uploadService->uploadToRemoteInstances($point, $input->getOption('remote'));
134+
135+
return 0;
136+
}
137+
138+
121139
$this->uploadService->uploadPoint($point);
122140

123141
return 0;

lib/Service/UploadService.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,34 @@ public function __construct(
129129
/**
130130
* @param RestoringPoint $point
131131
*
132-
* @throws ExternalFolderNotFoundException
133132
* @throws NotFoundException
134133
* @throws NotPermittedException
135-
* @throws RemoteInstanceNotFoundException
136-
* @throws RestoringPointPackException
137134
* @throws RestoringPointLockException
135+
* @throws RestoringPointPackException
138136
*/
139-
public function uploadPoint(RestoringPoint $point): void {
137+
public function initUpload(RestoringPoint $point): void {
140138
if (!$point->isStatus(RestoringPoint::STATUS_PACKED)
141139
|| $point->isStatus(RestoringPoint::STATUS_PACKING)) {
142140
throw new RestoringPointPackException('restoring point is not packed');
143141
}
144142

145143
$this->metadataService->isLock($point);
146-
147144
$this->pointService->initBaseFolder($point);
145+
}
146+
148147

148+
/**
149+
* @param RestoringPoint $point
150+
*
151+
* @throws ExternalFolderNotFoundException
152+
* @throws NotFoundException
153+
* @throws NotPermittedException
154+
* @throws RemoteInstanceNotFoundException
155+
* @throws RestoringPointPackException
156+
* @throws RestoringPointLockException
157+
*/
158+
public function uploadPoint(RestoringPoint $point): void {
159+
$this->initUpload($point);
149160
$this->uploadToRemoteInstances($point);
150161
$this->uploadToExternalFolder($point);
151162
}

0 commit comments

Comments
 (0)