• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 20907588007

12 Jan 2026 03:57AM UTC coverage: 43.867%. First build
20907588007

Pull #6436

github

web-flow
Merge 9c5490a63 into 8fe916f99
Pull Request #6436: feat: async parallel signing

242 of 775 new or added lines in 26 files covered. (31.23%)

6920 of 15775 relevant lines covered (43.87%)

4.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/lib/BackgroundJob/CleanupStaleSigningStatus.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\BackgroundJob;
10

11
use DateTime;
12
use OCA\Libresign\Db\FileMapper;
13
use OCA\Libresign\Enum\FileStatus;
14
use OCP\AppFramework\Utility\ITimeFactory;
15
use OCP\BackgroundJob\IJob;
16
use OCP\BackgroundJob\TimedJob;
17
use Psr\Log\LoggerInterface;
18

19
/**
20
 * Background job to clean up stale SIGNING_IN_PROGRESS statuses
21
 *
22
 * If a signing process is interrupted (server crash, PHP timeout, etc.),
23
 * files can get stuck in SIGNING_IN_PROGRESS status. This job reverts
24
 * those statuses back to ABLE_TO_SIGN after a timeout period.
25
 */
26
class CleanupStaleSigningStatus extends TimedJob {
27
        /** @var int Timeout in minutes - files in IN_PROGRESS for longer will be reverted */
28
        private const STALE_TIMEOUT_MINUTES = 10;
29

30
        public function __construct(
31
                ITimeFactory $time,
32
                private FileMapper $fileMapper,
33
                private LoggerInterface $logger,
34
        ) {
NEW
35
                parent::__construct($time);
×
36

37
                // Run every 5 minutes
NEW
38
                $this->setInterval(60 * 5);
×
NEW
39
                $this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
×
40
        }
41

42
        /**
43
         * @inheritDoc
44
         */
45
        #[\Override]
46
        public function run($argument): void {
NEW
47
                $staleThreshold = new DateTime();
×
NEW
48
                $staleThreshold->modify('-' . self::STALE_TIMEOUT_MINUTES . ' minutes');
×
49

50
                try {
NEW
51
                        $staleFiles = $this->fileMapper->findStaleSigningInProgress($staleThreshold);
×
52

NEW
53
                        $revertedCount = 0;
×
NEW
54
                        foreach ($staleFiles as $file) {
×
NEW
55
                                $file->setStatusEnum(FileStatus::ABLE_TO_SIGN);
×
NEW
56
                                $meta = $file->getMetadata() ?? [];
×
NEW
57
                                $meta['status_changed_at'] = (new DateTime())->format(DateTime::ATOM);
×
NEW
58
                                $file->setMetadata($meta);
×
NEW
59
                                $this->fileMapper->update($file);
×
NEW
60
                                $revertedCount++;
×
61
                        }
NEW
62
                } catch (\Exception $e) {
×
NEW
63
                        $this->logger->error(
×
NEW
64
                                'Failed to cleanup stale signing statuses: {message}',
×
NEW
65
                                ['message' => $e->getMessage(), 'exception' => $e]
×
NEW
66
                        );
×
67
                }
68
        }
69
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc