added relative_path functionality to DiffTaskService

This commit is contained in:
Jonathan Treffler 2024-01-23 22:12:02 +01:00 committed by root
parent c13e8dfcb2
commit 9280da6f0e

View file

@ -7,6 +7,7 @@ use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCA\GroupfolderFilesystemSnapshots\Exceptions\NotFoundException;
use OCA\GroupfolderFilesystemSnapshots\Exceptions\InvalidRelativePathException;
use OCA\GroupfolderFilesystemSnapshots\Db\DiffTask;
use OCA\GroupfolderFilesystemSnapshots\Db\DiffTaskMapper;
use OCA\GroupfolderFilesystemSnapshots\Db\DiffTaskResult;
@ -14,14 +15,17 @@ use OCA\GroupfolderFilesystemSnapshots\Db\DiffTaskResultMapper;
use OCA\GroupfolderFilesystemSnapshots\Manager\PathManager;
use OCA\GroupfolderFilesystemSnapshots\RecursiveDiff;
class DiffTaskService {
private DiffTaskMapper $mapper;
private DiffTaskResultMapper $diffTaskResultMapper;
private PathManager $pathManager;
public function __construct(DiffTaskMapper $mapper, DiffTaskResultMapper $diffTaskResultMapper, PathManager $pathManager){
public function __construct(
DiffTaskMapper $mapper,
DiffTaskResultMapper $diffTaskResultMapper,
PathManager $pathManager,
){
$this->mapper = $mapper;
$this->diffTaskResultMapper = $diffTaskResultMapper;
$this->pathManager = $pathManager;
@ -54,12 +58,17 @@ class DiffTaskService {
}
}
function create(int $groupfolderId, string $snapshotId, string $userId, Callable $progressCallback = null): DiffTask {
$snapshotPath = $this->pathManager->getGroupFolderSnapshotDirectory($groupfolderId, $snapshotId);
$groupfolderPath = $this->pathManager->getGroupFolderDirectory($groupfolderId);
function create(string $relativePathInGroupfolder, int $groupfolderId, string $snapshotId, string $userId, Callable $progressCallback = null): ?DiffTask {
$snapshotPath = $this->pathManager->getGroupFolderSnapshotDirectory($groupfolderId, $relativePathInGroupfolder, $snapshotId);
$groupfolderPath = $this->pathManager->getGroupFolderDirectory($groupfolderId, $relativePathInGroupfolder);
if(!($snapshotPath && $groupfolderPath)) {
throw new InvalidRelativePathException;
}
$newTask = new DiffTask();
$newTask->setGroupfolderId($groupfolderId);
$newTask->setRelativePath($relativePathInGroupfolder);
$newTask->setSnapshotId($snapshotId);
$newTask->setTimestamp(time());
$newTask->setUserId($userId);