Skip to content

Commit 2c56dfb

Browse files
committed
fix: attempt to repair upload folder permissions
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent a6826ee commit 2c56dfb

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

apps/dav/lib/RootCollection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public function __construct() {
175175
\OC::$server->query(CleanupService::class),
176176
$rootFolder,
177177
$userSession,
178+
$logger,
178179
);
179180
$uploadCollection->disableListing = $disableListing;
180181

apps/dav/lib/Upload/RootCollection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
use OCP\Files\IRootFolder;
3030
use OCP\IUserSession;
31+
use Psr\Log\LoggerInterface;
3132
use Sabre\DAVACL\AbstractPrincipalCollection;
3233
use Sabre\DAVACL\PrincipalBackend;
3334

@@ -37,6 +38,7 @@ public function __construct(PrincipalBackend\BackendInterface $principalBackend,
3738
private CleanupService $cleanupService,
3839
private IRootFolder $rootFolder,
3940
private IUserSession $userSession,
41+
private LoggerInterface $logger,
4042
) {
4143
parent::__construct($principalBackend, $principalPrefix);
4244
}
@@ -45,7 +47,7 @@ public function __construct(PrincipalBackend\BackendInterface $principalBackend,
4547
* @inheritdoc
4648
*/
4749
public function getChildForPrincipal(array $principalInfo): UploadHome {
48-
return new UploadHome($principalInfo, $this->cleanupService, $this->rootFolder, $this->userSession);
50+
return new UploadHome($principalInfo, $this->cleanupService, $this->rootFolder, $this->userSession, $this->logger);
4951
}
5052

5153
/**

apps/dav/lib/Upload/UploadHome.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727

2828
use OC\Files\View;
2929
use OCA\DAV\Connector\Sabre\Directory;
30+
use OCP\Constants;
3031
use OCP\Files\Folder;
3132
use OCP\Files\IRootFolder;
3233
use OCP\Files\NotFoundException;
3334
use OCP\IUserSession;
35+
use Psr\Log\LoggerInterface;
3436
use Sabre\DAV\Exception\Forbidden;
3537
use Sabre\DAV\ICollection;
3638

@@ -42,6 +44,7 @@ public function __construct(
4244
private CleanupService $cleanupService,
4345
private IRootFolder $rootFolder,
4446
private IUserSession $userSession,
47+
private LoggerInterface $logger,
4548
) {
4649
}
4750

@@ -109,6 +112,12 @@ private function getUploadFolder(): Folder {
109112

110113
private function impl(): Directory {
111114
$folder = $this->getUploadFolder();
115+
if (!$folder->isCreatable()) {
116+
$user = $this->userSession->getUser();
117+
$this->logger->warning('Upload home not writable for ' . $user->getUID() . ', attempting to fix', ['permissions' => $folder->getPermissions()]);
118+
$cache = $folder->getStorage()->getCache();
119+
$cache->update($folder->getId(), ['permissions', Constants::PERMISSION_ALL]);
120+
}
112121
$view = new View($folder->getPath());
113122
return new Directory($view, $folder);
114123
}

0 commit comments

Comments
 (0)