Skip to content

Commit

Permalink
use files' owner
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
  • Loading branch information
ArtificialOwl committed Oct 23, 2021
1 parent f0c5582 commit 8b750c2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
5 changes: 3 additions & 2 deletions lib/Controller/LocalController.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,10 @@ public function unsetExternalFolder(int $storageId): DataResponse {
*/
private function initActionScanLocalFolder(int $fileId): DataResponse {
try {
$point = $this->filesService->getPointFromFileId($fileId);
$userId = $this->userSession->getUser()->getUID();
$point = $this->filesService->getPointFromFileId($fileId, $userId);
$event = new BackupEvent();
$event->setAuthor($this->userSession->getUser()->getUID());
$event->setAuthor($userId);
$event->setData(['fileId' => $fileId]);
$event->setType('ScanLocalFolder');

Expand Down
32 changes: 10 additions & 22 deletions lib/Cron/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
use ArtificialOwl\MySmallPhpTools\Traits\TArrayTools;
use OC\BackgroundJob\TimedJob;
use OCA\Backup\Db\EventRequest;
use OCA\Backup\Exceptions\RestoringPointNotFoundException;
use OCA\Backup\Model\BackupEvent;
use OCA\Backup\Service\ConfigService;
use OCA\Backup\Service\CronService;
use OCA\Backup\Service\FilesService;
use OCA\Backup\Service\PointService;

/**
* Class Event
Expand All @@ -52,6 +52,9 @@ class Event extends TimedJob {
/** @var EventRequest */
private $eventRequest;

/** @var PointService */
private $pointService;

/** @var FilesService */
private $filesService;

Expand All @@ -66,19 +69,22 @@ class Event extends TimedJob {
* Event constructor.
*
* @param EventRequest $eventRequest
* @param PointService $pointService
* @param FilesService $filesService
* @param CronService $cronService
* @param ConfigService $configService
*/
public function __construct(
EventRequest $eventRequest,
PointService $pointService,
FilesService $filesService,
CronService $cronService,
ConfigService $configService
) {
$this->setInterval(1);

$this->eventRequest = $eventRequest;
$this->pointService = $pointService;
$this->filesService = $filesService;
$this->cronService = $cronService;
$this->configService = $configService;
Expand Down Expand Up @@ -106,28 +112,10 @@ protected function run($argument) {
*/
private function scanLocalFolder(BackupEvent $event): void {
$data = $event->getData();
try {
$point = $this->filesService->getPointFromFileId($this->getInt('fileId', $data));
$this->failEvent($event, 'A similar restoring point already exists (id=' . $point->getId() . ')');

return;
} catch (RestoringPointNotFoundException $e) {
}


//// $scan = $this->pointService->scanPoint($pointId);
//
// $point = new RestoringPoint();
// $point->setId($pointId);
//// $this->scanBaseFolder($point);
//
//
// $point = $this->pointService->generatePointFromBackupFS($pointId);
// // TODO: display info about the RP and ask for a confirmation before saving into database
//
//// echo json_encode($point) . "\n";
// $this->pointRequest->save($point);
$fileId = $this->getInt('fileId', $data);
$owner = $event->getAuthor();

$point = $this->pointService->generatePointFromFolder($fileId, $owner);

$this->successEvent($event);
}
Expand Down

0 comments on commit 8b750c2

Please sign in to comment.