mirror of
https://github.com/nextcloud/server.git
synced 2025-04-12 12:48:49 +00:00
fix: attempt to repair upload folder permissions
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
a6826eeee5
commit
2c56dfba84
3 changed files with 13 additions and 1 deletions
apps/dav/lib
|
@ -175,6 +175,7 @@ class RootCollection extends SimpleCollection {
|
|||
\OC::$server->query(CleanupService::class),
|
||||
$rootFolder,
|
||||
$userSession,
|
||||
$logger,
|
||||
);
|
||||
$uploadCollection->disableListing = $disableListing;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace OCA\DAV\Upload;
|
|||
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\IUserSession;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Sabre\DAVACL\AbstractPrincipalCollection;
|
||||
use Sabre\DAVACL\PrincipalBackend;
|
||||
|
||||
|
@ -37,6 +38,7 @@ class RootCollection extends AbstractPrincipalCollection {
|
|||
private CleanupService $cleanupService,
|
||||
private IRootFolder $rootFolder,
|
||||
private IUserSession $userSession,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
parent::__construct($principalBackend, $principalPrefix);
|
||||
}
|
||||
|
@ -45,7 +47,7 @@ class RootCollection extends AbstractPrincipalCollection {
|
|||
* @inheritdoc
|
||||
*/
|
||||
public function getChildForPrincipal(array $principalInfo): UploadHome {
|
||||
return new UploadHome($principalInfo, $this->cleanupService, $this->rootFolder, $this->userSession);
|
||||
return new UploadHome($principalInfo, $this->cleanupService, $this->rootFolder, $this->userSession, $this->logger);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,10 +27,12 @@ namespace OCA\DAV\Upload;
|
|||
|
||||
use OC\Files\View;
|
||||
use OCA\DAV\Connector\Sabre\Directory;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\Folder;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\IUserSession;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Sabre\DAV\Exception\Forbidden;
|
||||
use Sabre\DAV\ICollection;
|
||||
|
||||
|
@ -42,6 +44,7 @@ class UploadHome implements ICollection {
|
|||
private CleanupService $cleanupService,
|
||||
private IRootFolder $rootFolder,
|
||||
private IUserSession $userSession,
|
||||
private LoggerInterface $logger,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -109,6 +112,12 @@ class UploadHome implements ICollection {
|
|||
|
||||
private function impl(): Directory {
|
||||
$folder = $this->getUploadFolder();
|
||||
if (!$folder->isCreatable()) {
|
||||
$user = $this->userSession->getUser();
|
||||
$this->logger->warning('Upload home not writable for ' . $user->getUID() . ', attempting to fix', ['permissions' => $folder->getPermissions()]);
|
||||
$cache = $folder->getStorage()->getCache();
|
||||
$cache->update($folder->getId(), ['permissions', Constants::PERMISSION_ALL]);
|
||||
}
|
||||
$view = new View($folder->getPath());
|
||||
return new Directory($view, $folder);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue