Skip to content

Commit abe2872

Browse files
authored
Merge pull request #78 from nextcloud/bugfix/noid/temp-cleanup
Clean up any temp files after each job
2 parents 404e676 + 819beff commit abe2872

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/BackgroundJob/ZipJob.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use OCA\FilesZip\Service\ZipService;
3131
use OCP\AppFramework\Utility\ITimeFactory;
3232
use OCP\BackgroundJob\QueuedJob;
33+
use OCP\ITempManager;
3334
use Psr\Log\LoggerInterface;
3435

3536
class ZipJob extends QueuedJob {
@@ -40,12 +41,15 @@ class ZipJob extends QueuedJob {
4041
private $notificationService;
4142
/** @var LoggerInterface */
4243
private $logger;
44+
/** @var ITempManager */
45+
private $tempManager;
4346

44-
public function __construct(ITimeFactory $timeFactory, ZipService $zipService, NotificationService $notificationService, LoggerInterface $logger) {
47+
public function __construct(ITimeFactory $timeFactory, ZipService $zipService, NotificationService $notificationService, LoggerInterface $logger, ITempManager $tempManager) {
4548
parent::__construct($timeFactory);
4649
$this->zipService = $zipService;
4750
$this->notificationService = $notificationService;
4851
$this->logger = $logger;
52+
$this->tempManager = $tempManager;
4953
}
5054

5155
public function getUid(): string {
@@ -67,6 +71,8 @@ protected function run($argument) {
6771
} catch (\Throwable $e) {
6872
$this->logger->error('Failed to create zip archive', ['exception' => $e]);
6973
$this->notificationService->sendNotificationOnFailure($this);
74+
} finally {
75+
$this->tempManager->clean();
7076
}
7177
}
7278
}

0 commit comments

Comments
 (0)