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

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2020-01-07 16:48:20 +0300
committerGitHub <noreply@github.com>2020-01-07 16:48:20 +0300
commit9702daaac73969139779146003cfa88f4b80a868 (patch)
tree716d28ddda80d48f76659050c9f039682737d47f /lib
parent4f2c57ff0028bd996b09649956a131b3175221ea (diff)
parent86b700cac5c631223ad7cd4a08dc6f3e33ed8604 (diff)
Properly setup the filesystem for put operations (#762)
Properly setup the filesystem for put operations
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/WopiController.php6
-rw-r--r--lib/Service/UserScopeService.php13
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php
index d485895c..cca4607d 100644
--- a/lib/Controller/WopiController.php
+++ b/lib/Controller/WopiController.php
@@ -444,9 +444,9 @@ class WopiController extends Controller {
}
$content = fopen('php://input', 'rb');
-
// Set the user to register the change under his name
$this->userScopeService->setUserScope($wopi->getEditorUid());
+ $this->userScopeService->setFilesystemScope($isPutRelative ? $wopi->getEditorUid() : $wopi->getOwnerUid());
try {
$this->retryOperation(function () use ($file, $content){
@@ -481,6 +481,8 @@ class WopiController extends Controller {
* Just actually routes to the PutFile, the implementation of PutFile
* handles both saving and saving as.* Given an access token and a fileId, replaces the files with the request body.
*
+ * FIXME Cleanup this code as is a lot of shared logic between putFile and putRelativeFile
+ *
* @PublicPage
* @NoCSRFRequired
*
@@ -582,9 +584,9 @@ class WopiController extends Controller {
}
$content = fopen('php://input', 'rb');
-
// Set the user to register the change under his name
$this->userScopeService->setUserScope($wopi->getEditorUid());
+ $this->userScopeService->setFilesystemScope($isPutRelative ? $wopi->getEditorUid() : $wopi->getOwnerUid());
try {
$this->retryOperation(function () use ($file, $content){
diff --git a/lib/Service/UserScopeService.php b/lib/Service/UserScopeService.php
index 769f2c9f..90cc73f8 100644
--- a/lib/Service/UserScopeService.php
+++ b/lib/Service/UserScopeService.php
@@ -52,4 +52,17 @@ class UserScopeService {
}
$this->userSession->setUser($user);
}
+
+ /**
+ * Setup the FS which is needed to emit hooks
+ *
+ * This is required for versioning/activity as the legacy filesystem hooks
+ * are not emitted if filesystem operations are executed though \OCP\Files\Node\File
+ *
+ * @param string $owner
+ */
+ public function setFilesystemScope(string $owner): void {
+ \OC_Util::tearDownFS();
+ \OC_Util::setupFS($owner);
+ }
}