Skip to content
Prev Previous commit
Next Next commit
fix: Do not cleanup on close
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and backportbot-nextcloud[bot] committed Mar 9, 2023
commit 9754f1f8e0aad8407ddf66a7fe806adec00d6b45
2 changes: 1 addition & 1 deletion lib/Cron/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function run($argument) {
$this->logger->error('Document ' . $session->getDocumentId() . ' has not been reset, as an error occured', ['exception' => $e]);
}
}
$removedSessions = $this->sessionService->removeInactiveSessions(null);
$removedSessions = $this->sessionService->removeInactiveSessionsWithoutSteps(null);
$this->logger->debug('Removed ' . $removedSessions . ' inactive sessions');
}
}
2 changes: 1 addition & 1 deletion lib/Db/SessionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function findAllInactive() {
return $this->findEntities($qb);
}

public function deleteInactive($documentId = -1) {
public function deleteInactiveWithoutSteps($documentId = -1) {
$qb = $this->db->getQueryBuilder();
$qb->select('session_id')
->from('text_steps');
Expand Down
14 changes: 2 additions & 12 deletions lib/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function create($fileId = null, $filePath = null, $token = null, $guestNa

$readOnly = $this->documentService->isReadOnly($file, $token);

$this->sessionService->removeInactiveSessions($file->getId());
$this->sessionService->removeInactiveSessionsWithoutSteps($file->getId());
$remainingSessions = $this->sessionService->getAllSessions($file->getId());
$freshSession = false;
if ($forceRecreate || count($remainingSessions) === 0) {
Expand Down Expand Up @@ -183,17 +183,7 @@ public function create($fileId = null, $filePath = null, $token = null, $guestNa

public function close($documentId, $sessionId, $sessionToken): DataResponse {
$this->sessionService->closeSession($documentId, $sessionId, $sessionToken);
$this->sessionService->removeInactiveSessions($documentId);
$activeSessions = $this->sessionService->getActiveSessions($documentId);
if (count($activeSessions) === 0) {
try {
$this->documentService->resetDocument($documentId);
$this->attachmentService->cleanupAttachments($documentId);
$this->logger->info('Reset unsaved changes of ' . $documentId);
} catch (DocumentHasUnsavedChangesException $e) {
$this->logger->error('Did not reset unsaved changes during close of ' . $documentId, ['exception' => $e]);
}
}
$this->sessionService->removeInactiveSessionsWithoutSteps($documentId);
return new DataResponse([]);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Service/SessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ public function findAllInactive() {
return $this->sessionMapper->findAllInactive();
}

public function removeInactiveSessions($documentId = -1) {
public function removeInactiveSessionsWithoutSteps($documentId = -1) {
// No need to clear the cache here as we already set a TTL
return $this->sessionMapper->deleteInactive($documentId);
return $this->sessionMapper->deleteInactiveWithoutSteps($documentId);
}

/**
Expand Down