Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps/dav
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-07-27 18:06:39 +0300
committerGitHub <noreply@github.com>2022-07-27 18:06:39 +0300
commita02dee7c69c66dd95defa5c0c8477b47f5299273 (patch)
tree2ad0d431c92b5252087258d0aea795b2bfd77b1c /apps/dav
parentd24823bda5c2fff264fb7d27f1cd2a8383515bcc (diff)
parent944675a4a2cf95d9b2c71f448cffd75c75829e8c (diff)
Merge pull request #32956 from nextcloud/fix/upload-folder-wrong-content
Handle file contained inside the uploads folder
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/BackgroundJob/UploadCleanup.php21
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/dav/lib/BackgroundJob/UploadCleanup.php b/apps/dav/lib/BackgroundJob/UploadCleanup.php
index f612f58cd7c..3a6f296deaf 100644
--- a/apps/dav/lib/BackgroundJob/UploadCleanup.php
+++ b/apps/dav/lib/BackgroundJob/UploadCleanup.php
@@ -37,15 +37,18 @@ use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
+use Psr\Log\LoggerInterface;
class UploadCleanup extends TimedJob {
private IRootFolder $rootFolder;
private IJobList $jobList;
+ private LoggerInterface $logger;
- public function __construct(ITimeFactory $time, IRootFolder $rootFolder, IJobList $jobList) {
+ public function __construct(ITimeFactory $time, IRootFolder $rootFolder, IJobList $jobList, LoggerInterface $logger) {
parent::__construct($time);
$this->rootFolder = $rootFolder;
$this->jobList = $jobList;
+ $this->logger = $logger;
// Run once a day
$this->setInterval(60 * 60 * 24);
@@ -61,19 +64,27 @@ class UploadCleanup extends TimedJob {
$userRoot = $userFolder->getParent();
/** @var Folder $uploads */
$uploads = $userRoot->get('uploads');
- /** @var Folder $uploadFolder */
$uploadFolder = $uploads->get($folder);
} catch (NotFoundException | NoUserException $e) {
$this->jobList->remove(self::class, $argument);
return;
}
- /** @var File[] $files */
- $files = $uploadFolder->getDirectoryListing();
-
// Remove if all files have an mtime of more than a day
$time = $this->time->getTime() - 60 * 60 * 24;
+ if (!($uploadFolder instanceof Folder)) {
+ $this->logger->error("Found a file inside the uploads folder. Uid: " . $uid . ' folder: ' . $folder);
+ if ($uploadFolder->getMTime() < $time) {
+ $uploadFolder->delete();
+ }
+ $this->jobList->remove(self::class, $argument);
+ return;
+ }
+
+ /** @var File[] $files */
+ $files = $uploadFolder->getDirectoryListing();
+
// The folder has to be more than a day old
$initial = $uploadFolder->getMTime() < $time;