aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@users.noreply.github.com>2025-02-06 16:16:31 +0100
committerGitHub <noreply@github.com>2025-02-06 16:16:31 +0100
commit796055e8b27b924cc5e7c1ba4c6595f4c6e7fb71 (patch)
treeea1e85a6f52041c91ca29b07ce1f1f08781f7cec
parent93c72f5675f391fb016f8f9aefc429c7bb0d459b (diff)
parent6744accdd9b1cf2a7e1c1c55f52f4981b30dfe8a (diff)
downloadnextcloud-server-796055e8b27b924cc5e7c1ba4c6595f4c6e7fb71.tar.gz
nextcloud-server-796055e8b27b924cc5e7c1ba4c6595f4c6e7fb71.zip
Merge pull request #48674 from nextcloud/jtr/fix-updater-cleanup-job-logging
-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..2396cde2290 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");
}
}
}