Properly setup the filesystem for put operations

This is required for versioning/activity as the legacy filesystem hooks
are not emitted otherwise, if filesystem operations are executed though
the \OCP\Files\Node\File API

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2020-01-02 22:15:59 +01:00
Родитель b7f467f4fb
Коммит 86b700cac5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4C614C6ED2CDE6DF
2 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -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){

Просмотреть файл

@ -48,4 +48,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);
}
}