Use the editor to edit save a file

Fixes #184

We should always open try to access the file from the editor point of
view. The only moment we can't do this is when we edit from a public
page.

This makes sure that the paths match properly for versions.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-07-10 10:00:54 +02:00
Родитель 2c68a4d196
Коммит 8f58e022c0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: F941078878347C0C
1 изменённых файлов: 7 добавлений и 8 удалений

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

@ -220,9 +220,15 @@ class WopiController extends Controller {
return new JSONResponse([], Http::STATUS_FORBIDDEN);
}
// Unless the editor is empty (public link) we modify the files as the current editor
$editor = $wopi->getEditorUid();
if ($editor === null) {
$editor = $wopi->getOwnerUid();
}
try {
/** @var File $file */
$userFolder = $this->rootFolder->getUserFolder($wopi->getOwnerUid());
$userFolder = $this->rootFolder->getUserFolder($editor);
$file = $userFolder->getById($fileId)[0];
if ($isPutRelative) {
@ -275,13 +281,6 @@ class WopiController extends Controller {
}
$content = fopen('php://input', 'rb');
// Setup the FS which is needed to emit hooks (versioning).
\OC_Util::tearDownFS();
if (!$isPutRelative) {
\OC_Util::setupFS($wopi->getOwnerUid());
} else {
\OC_Util::setupFS($wopi->getEditorUid());
}
// Set the user to register the change under his name
$editor = $this->userManager->get($wopi->getEditorUid());