1
0
mirror of https://github.com/ONLYOFFICE/onlyoffice-owncloud.git synced 2025-07-30 10:43:07 +03:00

unlock federated key

This commit is contained in:
Antipkin-A
2020-11-27 16:18:35 +03:00
committed by Sergey Linnik
parent 1c2f58a82b
commit 32f48d081e
3 changed files with 16 additions and 3 deletions

View File

@ -520,7 +520,7 @@ class CallbackController extends Controller {
if ($isForcesave if ($isForcesave
&& $file->getStorage()->instanceOfStorage(SharingExternalStorage::class)) { && $file->getStorage()->instanceOfStorage(SharingExternalStorage::class)) {
KeyManager::lockFederatedKey($file, $isForcesave); KeyManager::lockFederatedKey($file, $isForcesave, null);
} }
//lock the key when forcesave and unlock if last forcesave is broken //lock the key when forcesave and unlock if last forcesave is broken
@ -531,6 +531,11 @@ class CallbackController extends Controller {
return $file->putContent($newData); return $file->putContent($newData);
}); });
if ($isForcesave
&& $file->getStorage()->instanceOfStorage(SharingExternalStorage::class)) {
KeyManager::lockFederatedKey($file, false, $isForcesave);
}
//unlock key for future federated save //unlock key for future federated save
KeyManager::lock($fileId, false); KeyManager::lock($fileId, false);
KeyManager::setForcesave($fileId, $isForcesave); KeyManager::setForcesave($fileId, $isForcesave);

View File

@ -117,6 +117,7 @@ class FederationController extends OCSController {
* @param string $shareToken - access token * @param string $shareToken - access token
* @param string $path - file path * @param string $path - file path
* @param bool $lock - status * @param bool $lock - status
* @param bool $fs - status
* *
* @return Result * @return Result
* *
@ -124,7 +125,7 @@ class FederationController extends OCSController {
* @NoCSRFRequired * @NoCSRFRequired
* @PublicPage * @PublicPage
*/ */
public function keylock($shareToken, $path, $lock) { public function keylock($shareToken, $path, $lock, $fs) {
list ($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path); list ($file, $error, $share) = $this->fileUtility->getFileByToken(null, $shareToken, $path);
if (isset($error)) { if (isset($error)) {
@ -135,6 +136,9 @@ class FederationController extends OCSController {
$fileId = $file->getId(); $fileId = $file->getId();
KeyManager::lock($fileId, $lock); KeyManager::lock($fileId, $lock);
if (!empty($fs)) {
KeyManager::setForcesave($fileId, $fs);
}
$this->logger->debug("Federated request lock for " . $fileId, ["app" => $this->appName]); $this->logger->debug("Federated request lock for " . $fileId, ["app" => $this->appName]);
return new Result(); return new Result();

View File

@ -159,8 +159,9 @@ class KeyManager {
* *
* @param File $file - file * @param File $file - file
* @param bool $lock - status * @param bool $lock - status
* @param bool $fs - status
*/ */
public static function lockFederatedKey($file, $lock = true) { public static function lockFederatedKey($file, $lock = true, $fs) {
$logger = \OC::$server->getLogger(); $logger = \OC::$server->getLogger();
$remote = $file->getStorage()->getRemote(); $remote = $file->getStorage()->getRemote();
@ -177,6 +178,9 @@ class KeyManager {
"lock" => $lock "lock" => $lock
] ]
]; ];
if (!empty($fs)) {
$data["body"]["fs"] = $fs;
}
$response = $client->post($remote . "/ocs/v2.php/apps/" . self::App_Name . "/api/v1/keylock?format=json", $data); $response = $client->post($remote . "/ocs/v2.php/apps/" . self::App_Name . "/api/v1/keylock?format=json", $data);
$body = \json_decode($response->getBody(), true); $body = \json_decode($response->getBody(), true);