зеркало из https://github.com/nextcloud/text.git
Open files read only if locked
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Родитель
8c00c8eb25
Коммит
53d1012f7f
|
@ -28,6 +28,7 @@ namespace OCA\Text\Service;
|
|||
|
||||
use Exception;
|
||||
use OC\Files\Node\File;
|
||||
use OCA\Text\AppInfo\Application;
|
||||
use OCA\Text\DocumentHasUnsavedChangesException;
|
||||
use OCA\Text\DocumentSaveConflictException;
|
||||
use OCA\Text\VersionMismatchException;
|
||||
|
@ -37,6 +38,7 @@ use OCP\AppFramework\Http\DataResponse;
|
|||
use OCP\AppFramework\Http\FileDisplayResponse;
|
||||
use OCP\AppFramework\Http\NotFoundResponse;
|
||||
use OCP\Constants;
|
||||
use OCP\Files\Lock\ILock;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\ILogger;
|
||||
use OCP\IRequest;
|
||||
|
@ -63,7 +65,6 @@ class ApiService {
|
|||
|
||||
public function create($fileId = null, $filePath = null, $token = null, $guestName = null, bool $forceRecreate = false): DataResponse {
|
||||
try {
|
||||
$readOnly = true;
|
||||
/** @var File $file */
|
||||
if ($token) {
|
||||
$file = $this->documentService->getFileByShareToken($token, $this->request->getParam('filePath'));
|
||||
|
@ -77,19 +78,14 @@ class ApiService {
|
|||
} catch (NotFoundException $e) {
|
||||
return new DataResponse([], Http::STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
try {
|
||||
$this->documentService->checkSharePermissions($token, Constants::PERMISSION_UPDATE);
|
||||
$readOnly = false;
|
||||
} catch (NotFoundException $e) {
|
||||
}
|
||||
} elseif ($fileId) {
|
||||
$file = $this->documentService->getFileById($fileId);
|
||||
$readOnly = !$file->isUpdateable();
|
||||
} else {
|
||||
return new DataResponse('No valid file argument provided', 500);
|
||||
}
|
||||
|
||||
$readOnly = $this->documentService->isReadOnly($file, $token);
|
||||
|
||||
$this->sessionService->removeInactiveSessions($file->getId());
|
||||
$activeSessions = $this->sessionService->getActiveSessions($file->getId());
|
||||
if ($forceRecreate || count($activeSessions) === 0) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче