зеркало из https://github.com/nextcloud/text.git
fix(reset): Reset all document sessions on upgrades from 4.0.0 or below
Fixes: #5420 Fixes: nextcloud/collectives#1270 Signed-off-by: Jonas <jonas@freesources.org> [skip ci]
This commit is contained in:
Родитель
be0b7b6a2c
Коммит
a74ae06ca9
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace OCA\Text\Migration;
|
||||
|
||||
use OCA\Text\Db\SessionMapper;
|
||||
use OCA\Text\Db\Document;
|
||||
use OCA\Text\Service\DocumentService;
|
||||
use OCP\IConfig;
|
||||
use OCP\Migration\IOutput;
|
||||
|
@ -25,31 +25,28 @@ class ResetSessionsBeforeYjs implements IRepairStep {
|
|||
* @return string
|
||||
*/
|
||||
public function getName(): string {
|
||||
return 'Force-reset all Text sessions before Yjs migration';
|
||||
return 'Force-reset all Text document sessions';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run(IOutput $output): void {
|
||||
$appVersion = $this->config->getAppValue('text', 'installed_version');
|
||||
|
||||
if (!$appVersion || version_compare($appVersion, '3.7.2') !== -1) {
|
||||
if (!$appVersion || version_compare($appVersion, '4.0.1') !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sessions = $this->sessionMapper->findAllDocuments();
|
||||
if (!$sessions) {
|
||||
$fileIds = array_map(static function (Document $document) {
|
||||
return $document->getId();
|
||||
}, $this->documentService->getAll());
|
||||
|
||||
if (!$fileIds) {
|
||||
return;
|
||||
}
|
||||
|
||||
$output->startProgress(count($sessions));
|
||||
foreach ($sessions as $session) {
|
||||
$documentId = $session->getDocumentId();
|
||||
$this->documentService->unlock($documentId);
|
||||
$this->documentService->resetDocument($documentId, true);
|
||||
$output->startProgress(count($fileIds));
|
||||
foreach ($fileIds as $fileId) {
|
||||
$this->documentService->unlock($fileId);
|
||||
$this->documentService->resetDocument($fileId, true);
|
||||
$output->advance();
|
||||
}
|
||||
$output->finishProgress();
|
||||
|
|
Загрузка…
Ссылка в новой задаче