Skip to content

Commit

Permalink
fix(cron): Cleanup old documents folders that got renamed during reset
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Jun 17, 2024
1 parent 8e7bc00 commit fe9a94f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Cron/Cleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@ protected function run($argument): void {
$this->logger->debug('Run cleanup job for text sessions');
$removedSessions = $this->sessionService->removeInactiveSessionsWithoutSteps(null);
$this->logger->debug('Removed ' . $removedSessions . ' inactive sessions');

$this->logger->debug('Run cleanup job for obsolete documents folders');
$this->documentService->cleanupOldDocumentsFolders();
}
}
12 changes: 12 additions & 0 deletions lib/Service/DocumentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,16 @@ public function clearAll(): void {
}
$this->ensureDocumentsFolder();
}

public function cleanupOldDocumentsFolders(): void {
try {
$appFolder = $this->getFullAppFolder();
foreach ($appFolder->getDirectoryListing() as $node) {
if (str_starts_with($node->getName(), 'documents_old_')) {
$node->delete();
}
}
} catch (NotFoundException) {
}
}
}

0 comments on commit fe9a94f

Please sign in to comment.