Skip to content

Commit

Permalink
get data also from groupfolders
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialOwl committed Oct 5, 2021
1 parent 217d863 commit 416dac1
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions lib/Listeners/NodeEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@
use ArtificialOwl\MySmallPhpTools\Traits\Nextcloud\nc23\TNC23Logger;
use OCA\Backup\AppInfo\Application;
use OCA\Backup\Model\ChangedFile;
use OCA\Backup\Service\ConfigService;
use OCA\Backup\Service\FilesService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Events\Node\NodeCreatedEvent;
use OCP\Files\Events\Node\NodeRenamedEvent;
use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\Files\NotFoundException;


/**
Expand All @@ -57,14 +59,19 @@ class NodeEvent implements IEventListener {
/** @var FilesService */
private $filesService;

/** @var ConfigService */
private $configService;


/**
* NodeEvent constructor.
*
* @param FilesService $filesService
* @param ConfigService $configService
*/
public function __construct(FilesService $filesService) {
public function __construct(FilesService $filesService, ConfigService $configService) {
$this->filesService = $filesService;
$this->configService = $configService;

$this->setup('app', Application::APP_ID);
}
Expand All @@ -87,8 +94,24 @@ public function handle(Event $event): void {
return;
}

$file = new ChangedFile($node->getPath());
$this->filesService->changedFile($file);
try {
$storage = $node->getStorage();
if (!$storage->isLocal()) {
return;
}

$filepath = $storage->getLocalFile($node->getInternalPath());
$root = $this->configService->getSystemValue('datadirectory');

if (strpos($filepath, $root) !== 0) {
return;
}

$filepath = substr($filepath, strlen($root));
$file = new ChangedFile($filepath);
$this->filesService->changedFile($file);
} catch (NotFoundException $e) {
}
}

}
Expand Down

0 comments on commit 416dac1

Please sign in to comment.