Skip to content

Commit

Permalink
Rename storage to rootFolder
Browse files Browse the repository at this point in the history
Signed-off-by: GitHub <[email protected]>
  • Loading branch information
Chartman123 authored Sep 24, 2024
1 parent 7832fff commit d179cd7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions lib/BackgroundJob/CleanupUploadedFilesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CleanupUploadedFilesJob extends TimedJob {
private const FILE_LIFETIME = '-1 hour';

public function __construct(
private IRootFolder $storage,
private IRootFolder $rootFolder,
private FormMapper $formMapper,
private UploadedFileMapper $uploadedFileMapper,
private LoggerInterface $logger,
Expand Down Expand Up @@ -69,7 +69,7 @@ public function run($argument): void {

$form = $this->formMapper->findById($uploadedFile->getFormId());
$usersToCleanup[$form->getOwnerId()] = true;
$userFolder = $this->storage->getUserFolder($form->getOwnerId());
$userFolder = $this->rootFolder->getUserFolder($form->getOwnerId());

$nodes = $userFolder->getById($uploadedFile->getFileId());

Expand All @@ -93,7 +93,7 @@ public function run($argument): void {
$deleted = 0;
foreach (array_keys($usersToCleanup) as $userId) {
$this->logger->info('Cleaning up empty folders for user {userId}.', ['userId' => $userId]);
$userFolder = $this->storage->getUserFolder($userId);
$userFolder = $this->rootFolder->getUserFolder($userId);

$unsubmittedFilesFolder = $userFolder->get(Constants::UNSUBMITTED_FILES_FOLDER);
if (!$unsubmittedFilesFolder instanceof Folder) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct(
private IL10N $l10n,
private LoggerInterface $logger,
private IUserManager $userManager,
private IRootFolder $storage,
private IRootFolder $rootFolder,
private UploadedFileMapper $uploadedFileMapper,
private IMimeTypeDetector $mimeTypeDetector,
) {
Expand Down Expand Up @@ -1253,7 +1253,7 @@ public function uploadFiles(int $formId, int $questionId, string $shareHash = ''
throw new OCSBadRequestException('Invalid file provided');
}

$userFolder = $this->storage->getUserFolder($form->getOwnerId());
$userFolder = $this->rootFolder->getUserFolder($form->getOwnerId());
$userFolder->getStorage()->verifyPath($path, $uploadedFile['name']);

$extraSettings = $question->getExtraSettings();
Expand Down Expand Up @@ -2217,7 +2217,7 @@ public function uploadFilesLegacy(int $formId, int $questionId, string $shareHas
throw new OCSBadRequestException('Invalid file provided');
}

$userFolder = $this->storage->getUserFolder($form->getOwnerId());
$userFolder = $this->rootFolder->getUserFolder($form->getOwnerId());

Check warning on line 2220 in lib/Controller/ApiController.php

View check run for this annotation

Codecov / codecov/patch

lib/Controller/ApiController.php#L2220

Added line #L2220 was not covered by tests
$userFolder->getStorage()->verifyPath($path, $uploadedFile['name']);

$extraSettings = $question->getExtraSettings();
Expand Down Expand Up @@ -2634,7 +2634,7 @@ private function storeAnswersForQuestion(Form $form, $submissionId, array $quest
$uploadedFile = $this->uploadedFileMapper->getByUploadedFileId($answer['uploadedFileId']);
$answerEntity->setFileId($uploadedFile->getFileId());

$userFolder = $this->storage->getUserFolder($form->getOwnerId());
$userFolder = $this->rootFolder->getUserFolder($form->getOwnerId());
$path = $this->formsService->getUploadedFilePath($form, $submissionId, $question['id'], $question['name'], $question['text']);

if ($userFolder->nodeExists($path)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Controller/ShareApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
private IUserManager $userManager,
private ISecureRandom $secureRandom,
private CirclesService $circlesService,
private IRootFolder $storage,
private IRootFolder $rootFolder,
private IManager $shareManager,
) {
parent::__construct($appName, $request);
Expand Down Expand Up @@ -261,7 +261,7 @@ public function updateShare(int $formId, int $shareId, array $keyValuePairs): Da
$formShare = $this->shareMapper->update($formShare);

if (in_array($formShare->getShareType(), [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_USERGROUP, IShare::TYPE_CIRCLE], true)) {
$userFolder = $this->storage->getUserFolder($form->getOwnerId());
$userFolder = $this->rootFolder->getUserFolder($form->getOwnerId());
$uploadedFilesFolderPath = $this->formsService->getFormUploadedFilesFolderPath($form);
if ($userFolder->nodeExists($uploadedFilesFolderPath)) {
$folder = $userFolder->get($uploadedFilesFolderPath);
Expand Down Expand Up @@ -558,7 +558,7 @@ public function updateShareLegacy(int $id, array $keyValuePairs): DataResponse {
$formShare = $this->shareMapper->update($formShare);

if (in_array($formShare->getShareType(), [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_USERGROUP, IShare::TYPE_CIRCLE], true)) {
$userFolder = $this->storage->getUserFolder($form->getOwnerId());
$userFolder = $this->rootFolder->getUserFolder($form->getOwnerId());

Check warning on line 561 in lib/Controller/ShareApiController.php

View check run for this annotation

Codecov / codecov/patch

lib/Controller/ShareApiController.php#L561

Added line #L561 was not covered by tests
$uploadedFilesFolderPath = $this->formsService->getFormUploadedFilesFolderPath($form);
if ($userFolder->nodeExists($uploadedFilesFolderPath)) {
$folder = $userFolder->get($uploadedFilesFolderPath);
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/FormsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct(
private IUserManager $userManager,
private ISecureRandom $secureRandom,
private CirclesService $circlesService,
private IRootFolder $storage,
private IRootFolder $rootFolder,
private IL10N $l10n,
private IMimeTypeDetector $mimeTypeDetector,
private IEventDispatcher $eventDispatcher,
Expand Down Expand Up @@ -742,7 +742,7 @@ public function getFilePath(Form $form): ?string {
return null;
}

$folder = $this->storage->getUserFolder($form->getOwnerId());
$folder = $this->rootFolder->getUserFolder($form->getOwnerId());
$nodes = $folder->getById($fileId);

if (empty($nodes)) {
Expand Down
8 changes: 4 additions & 4 deletions lib/Service/SubmissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(
private SubmissionMapper $submissionMapper,
private AnswerMapper $answerMapper,
private UploadedFileMapper $uploadedFileMapper,
private IRootFolder $storage,
private IRootFolder $rootFolder,
private IConfig $config,
private IL10N $l10n,
private LoggerInterface $logger,
Expand Down Expand Up @@ -146,9 +146,9 @@ public function writeFileToCloud(Form $form, string $path, string $fileFormat, ?

/** @var \OCP\Files\Folder|File $node */
if ($ownerId) {
$node = $this->storage->getUserFolder($ownerId)->get($path);
$node = $this->rootFolder->getUserFolder($ownerId)->get($path);

Check warning on line 149 in lib/Service/SubmissionService.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/SubmissionService.php#L149

Added line #L149 was not covered by tests
} else {
$node = $this->storage->getUserFolder($this->currentUser->getUID())->get($path);
$node = $this->rootFolder->getUserFolder($this->currentUser->getUID())->get($path);
}

// If chosen path is a file with expected extension - overwrite it and use parent folder otherwise.
Expand Down Expand Up @@ -417,7 +417,7 @@ public function validateSubmission(array $questions, array $answers, string $for
return sprintf('File "%s" for question "%s" not exists anymore. Please delete and re-upload the file.', $answer['fileName'] ?? $answer['uploadedFileId'], $question['text']);
}

$nodes = $this->storage->getUserFolder($formOwnerId)->getById($uploadedFile->getFileId());
$nodes = $this->rootFolder->getUserFolder($formOwnerId)->getById($uploadedFile->getFileId());

Check warning on line 420 in lib/Service/SubmissionService.php

View check run for this annotation

Codecov / codecov/patch

lib/Service/SubmissionService.php#L420

Added line #L420 was not covered by tests
if (empty($nodes)) {
return sprintf('File "%s" for question "%s" not exists anymore. Please delete and re-upload the file.', $answer['fileName'] ?? $answer['uploadedFileId'], $question['text']);
}
Expand Down

0 comments on commit d179cd7

Please sign in to comment.