aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh <josh.t.richards@gmail.com>2024-10-12 19:03:55 -0400
committerLouis Chemineau <louis@chmn.me>2025-02-06 11:09:21 +0100
commitcd6ac0470e6d525f59bf004e66c56826809027a9 (patch)
tree7660ca371e753d34f2e241d05fe8add7a956ec78
parentd05b5e3068441470ed72f3ef29037932006d352d (diff)
downloadnextcloud-server-cd6ac0470e6d525f59bf004e66c56826809027a9.tar.gz
nextcloud-server-cd6ac0470e6d525f59bf004e66c56826809027a9.zip
fix(updater): make clean-up job more robust / easier to debug
Signed-off-by: Josh <josh.t.richards@gmail.com>
-rw-r--r--core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php b/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php
index 231caa683af..bb3dc6b2a45 100644
--- a/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php
+++ b/core/BackgroundJobs/BackgroundCleanupUpdaterBackupsJob.php
@@ -28,17 +28,20 @@ class BackgroundCleanupUpdaterBackupsJob extends QueuedJob {
* @param array $argument
*/
public function run($argument): void {
+ $this->log->info("Running background job to clean-up outdated updater backups");
+
$updateDir = $this->config->getSystemValue('updatedirectory', null) ?? $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data');
$instanceId = $this->config->getSystemValue('instanceid', null);
if (!is_string($instanceId) || empty($instanceId)) {
+ $this->log->error("Skipping updater backup clean-up - instanceId is missing!");
return;
}
$updaterFolderPath = $updateDir . '/updater-' . $instanceId;
$backupFolderPath = $updaterFolderPath . '/backups';
if (file_exists($backupFolderPath)) {
- $this->log->info("$backupFolderPath exists - start to clean it up");
+ $this->log->debug("Updater backup folder detected: $backupFolderPath");
$dirList = [];
$dirs = new \DirectoryIterator($backupFolderPath);
@@ -52,6 +55,8 @@ class BackgroundCleanupUpdaterBackupsJob extends QueuedJob {
$realPath = $dir->getRealPath();
if ($realPath === false) {
+ $pathName = $dir->getPathname();
+ $this->log->warning("Skipping updater backup folder: $pathName (not found)");
continue;
}
@@ -61,15 +66,18 @@ class BackgroundCleanupUpdaterBackupsJob extends QueuedJob {
ksort($dirList);
// drop the newest 3 directories
$dirList = array_slice($dirList, 0, -3);
- $this->log->info('List of all directories that will be deleted: ' . json_encode($dirList));
+ $this->log->debug('Updater backup folders that will be deleted: ' . json_encode($dirList));
foreach ($dirList as $dir) {
$this->log->info("Removing $dir ...");
- \OC_Helper::rmdirr($dir);
+ $result = \OC_Helper::rmdirr($dir);
+ if (!$result) {
+ $this->log->error('Could not remove updater backup folder $dir');
+ }
}
- $this->log->info('Cleanup finished');
+ $this->log->info('Background job to clean-up updater backups has finished');
} else {
- $this->log->info("Could not find updater directory $backupFolderPath - cleanup step not needed");
+ $this->log->warning("Skipping updater backup clean-up - could not find updater backup folder $backupFolderPath");
}
}
}