migrate therinaldos.com data
Build & Deploy to DigitalOcean Space / build (push) Failing after 2m38s

This commit is contained in:
2024-05-05 15:50:45 -04:00
commit ef1ff240d4
23182 changed files with 3801898 additions and 0 deletions
@@ -0,0 +1,115 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Daniel Kesselberg <mail@danielkesselberg.de>
* @author Joas Schilling <coding@schilljs.com>
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\BackgroundJob;
use OCP\ILogger;
/**
* This interface represend a backgroud job run with cron
*
* To implement a background job, you must extend either \OCP\BackgroundJob\Job,
* \OCP\BackgroundJob\TimedJob or \OCP\BackgroundJob\QueuedJob
*
* @since 7.0.0
*/
interface IJob {
/**
* @since 24.0.0
*/
public const TIME_INSENSITIVE = 0;
/**
* @since 24.0.0
*/
public const TIME_SENSITIVE = 1;
/**
* Run the background job with the registered argument
*
* @param IJobList $jobList The job list that manages the state of this job
* @param ILogger|null $logger
* @since 7.0.0
* @deprecated since 25.0.0 Use start() instead. This method will be removed
* with the ILogger interface
*/
public function execute(IJobList $jobList, ILogger $logger = null);
/**
* Start the background job with the registered argument
*
* This methods will take care of running the background job, of initializing
* the state and cleaning up the job list after running the job.
*
* For common background job scenario, you will want to use TimedJob or QueuedJob
* instead of overwritting this method.
*
* @param IJobList $jobList The job list that manages the state of this job
* @since 25.0.0
*/
public function start(IJobList $jobList): void;
/**
* @since 7.0.0
*/
public function setId(int $id);
/**
* @since 7.0.0
*/
public function setLastRun(int $lastRun);
/**
* @param mixed $argument
* @since 7.0.0
*/
public function setArgument($argument);
/**
* Get the id of the background job
* This id is determined by the job list when a job is added to the list
*
* @return int
* @since 7.0.0
*/
public function getId();
/**
* Get the last time this job was run as unix timestamp
*
* @return int
* @since 7.0.0
*/
public function getLastRun();
/**
* Get the argument associated with the background job
* This is the argument that will be passed to the background job
*
* @return mixed
* @since 7.0.0
*/
public function getArgument();
}
@@ -0,0 +1,171 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Joas Schilling <coding@schilljs.com>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Noveen Sachdeva <noveen.sachdeva@research.iiit.ac.in>
* @author Robin Appelman <robin@icewind.nl>
* @author Robin McCorkell <robin@mccorkell.me.uk>
* @author Côme Chilliet <come.chilliet@nextcloud.com>
*
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCP\BackgroundJob;
/**
* Interface IJobList
*
* This interface provides functions to register background jobs
*
* To create a new background job create a new class that inherits from either
* \OC\BackgroundJob\Job, \OC\BackgroundJob\QueuedJob or
* \OC\BackgroundJob\TimedJob and register it using ->add($job, $argument),
* $argument will be passed to the run() function of the job when the job is
* executed.
*
* A regular job will be executed every time cron.php is run, a QueuedJob will
* only run once and a TimedJob will only run at a specific interval which is to
* be specified in the constructor of the job by calling
* $this->setInterval($interval) with $interval in seconds.
*
* This interface should be used directly and not implemented by an application.
* The implementation is provided by the server.
*
* @since 7.0.0
*/
interface IJobList {
/**
* Add a job to the list
*
* @param IJob|class-string<IJob> $job
* @param mixed $argument The argument to be passed to $job->run() when the job is executed
* @since 7.0.0
*/
public function add($job, $argument = null): void;
/**
* Add a job to the list but only run it after the given timestamp
*
* For cron background jobs this means the job will likely run shortly after the timestamp
* has been reached. For ajax background jobs the job might only run when users are active
* on the instance again.
*
* @param class-string<IJob> $job
* @param mixed $argument The serializable argument to be passed to $job->run() when the job is executed
* @since 28.0.0
*/
public function scheduleAfter(string $job, int $runAfter, $argument = null): void;
/**
* Remove a job from the list
*
* @param IJob|class-string<IJob> $job
* @param mixed $argument
* @since 7.0.0
*/
public function remove($job, $argument = null): void;
/**
* check if a job is in the list
*
* @param IJob|class-string<IJob> $job
* @param mixed $argument
* @since 7.0.0
*/
public function has($job, $argument): bool;
/**
* Get jobs matching the search
*
* @param IJob|class-string<IJob>|null $job
* @return array<IJob>
* @since 25.0.0
* @deprecated 26.0.0 Use getJobsIterator instead to avoid duplicated job objects
*/
public function getJobs($job, ?int $limit, int $offset): array;
/**
* Get jobs matching the search
*
* @param IJob|class-string<IJob>|null $job
* @return iterable<IJob>
* @since 26.0.0
*/
public function getJobsIterator($job, ?int $limit, int $offset): iterable;
/**
* get the next job in the list
*
* @since 7.0.0 - In 24.0.0 parameter $onlyTimeSensitive got added
*/
public function getNext(bool $onlyTimeSensitive = false): ?IJob;
/**
* @since 7.0.0
*/
public function getById(int $id): ?IJob;
/**
* @since 23.0.0
*/
public function getDetailsById(int $id): ?array;
/**
* set the job that was last ran to the current time
*
* @since 7.0.0
*/
public function setLastJob(IJob $job): void;
/**
* Remove the reservation for a job
*
* @since 9.1.0
*/
public function unlockJob(IJob $job): void;
/**
* set the lastRun of $job to now
*
* @since 7.0.0
*/
public function setLastRun(IJob $job): void;
/**
* set the run duration of $job
*
* @since 12.0.0
*/
public function setExecutionTime(IJob $job, int $timeTaken): void;
/**
* Reset the $job so it executes on the next trigger
*
* @since 23.0.0
*/
public function resetBackgroundJob(IJob $job): void;
/**
* Checks whether a job of the passed class was reserved to run
* in the last 6h
*
* @param string|null $className
* @return bool
* @since 27.0.0
*/
public function hasReservedJob(?string $className): bool;
}
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023, Marcel Klehr <mklehr@gmx.net>
*
* @author Marcel Klehr <mklehr@gmx.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\BackgroundJob;
/**
* @since 27.0.0
*/
interface IParallelAwareJob {
/**
* Set this to false to prevent two Jobs from the same class from running in parallel
*
* @param bool $allow
* @return void
* @since 27.0.0
*/
public function setAllowParallelRuns(bool $allow): void;
/**
* @return bool
* @since 27.0.0
*/
public function getAllowParallelRuns(): bool;
}
@@ -0,0 +1,165 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\ILogger;
use Psr\Log\LoggerInterface;
/**
* Base class for background jobs
*
* This is here if you want to do advanced stuff in your background jobs.
* For the most common use cases have a look at QueuedJob and TimedJob
*
* @since 15.0.0
*/
abstract class Job implements IJob, IParallelAwareJob {
protected int $id = 0;
protected int $lastRun = 0;
protected $argument;
protected ITimeFactory $time;
protected bool $allowParallelRuns = true;
private ?ILogger $logger = null;
/**
* @since 15.0.0
*/
public function __construct(ITimeFactory $time) {
$this->time = $time;
}
/**
* The function to prepare the execution of the job.
*
*
* @param IJobList $jobList
* @param ILogger|null $logger
*
* @since 15.0.0
*/
public function execute(IJobList $jobList, ILogger $logger = null) {
$this->logger = $logger;
$this->start($jobList);
}
/**
* @inheritdoc
* @since 25.0.0
*/
public function start(IJobList $jobList): void {
$jobList->setLastRun($this);
$logger = $this->logger ?? \OCP\Server::get(LoggerInterface::class);
try {
$jobStartTime = $this->time->getTime();
$logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']);
$this->run($this->argument);
$timeTaken = $this->time->getTime() - $jobStartTime;
$logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']);
$jobList->setExecutionTime($this, $timeTaken);
} catch (\Throwable $e) {
if ($logger) {
$logger->error('Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')', [
'app' => 'core',
'exception' => $e,
]);
}
}
}
/**
* @since 15.0.0
*/
final public function setId(int $id) {
$this->id = $id;
}
/**
* @since 15.0.0
*/
final public function setLastRun(int $lastRun) {
$this->lastRun = $lastRun;
}
/**
* @since 15.0.0
*/
public function setArgument($argument) {
$this->argument = $argument;
}
/**
* @since 15.0.0
*/
final public function getId(): int {
return $this->id;
}
/**
* @since 15.0.0
*/
final public function getLastRun(): int {
return $this->lastRun;
}
/**
* @since 15.0.0
*/
public function getArgument() {
return $this->argument;
}
/**
* Set this to false to prevent two Jobs from this class from running in parallel
*
* @param bool $allow
* @return void
* @since 27.0.0
*/
public function setAllowParallelRuns(bool $allow): void {
$this->allowParallelRuns = $allow;
}
/**
* @return bool
* @since 27.0.0
*/
public function getAllowParallelRuns(): bool {
return $this->allowParallelRuns;
}
/**
* The actual function that is called to run the job
*
* @param $argument
*
* @since 15.0.0
*/
abstract protected function run($argument);
}
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\BackgroundJob;
use OCP\ILogger;
/**
* Simple base class for a one time background job
*
* @since 15.0.0
*/
abstract class QueuedJob extends Job {
/**
* Run the job, then remove it from the joblist
*
* @param IJobList $jobList
* @param ILogger|null $logger
*
* @since 15.0.0
* @deprecated since 25.0.0 Use start() instead. This method will be removed
* with the ILogger interface
*/
final public function execute($jobList, ILogger $logger = null) {
$this->start($jobList);
}
/**
* Run the job, then remove it from the joblist
*
* @since 25.0.0
*/
final public function start(IJobList $jobList): void {
$jobList->remove($this, $this->argument);
parent::start($jobList);
}
}
@@ -0,0 +1,105 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCP\BackgroundJob;
use OCP\ILogger;
/**
* Simple base class to extend to run periodic background jobs.
* Call setInterval with your desired interval in seconds from the constructor.
*
* @since 15.0.0
*/
abstract class TimedJob extends Job {
protected int $interval = 0;
protected int $timeSensitivity = IJob::TIME_SENSITIVE;
/**
* Set the interval for the job
*
* @param int $seconds the time to pass between two runs of the same job in seconds
*
* @since 15.0.0
*/
public function setInterval(int $seconds) {
$this->interval = $seconds;
}
/**
* Whether the background job is time sensitive and needs to run soon after
* the scheduled interval, of if it is okay to be delayed until a later time.
*
* @return bool
* @since 24.0.0
*/
public function isTimeSensitive(): bool {
return $this->timeSensitivity === IJob::TIME_SENSITIVE;
}
/**
* If your background job is not time sensitive (sending instant email
* notifications, etc.) it would be nice to set it to IJob::TIME_INSENSITIVE
* This way the execution can be delayed during high usage times.
*
* @param int $sensitivity
* @psalm-param IJob::TIME_* $sensitivity
* @return void
* @since 24.0.0
*/
public function setTimeSensitivity(int $sensitivity): void {
if ($sensitivity !== IJob::TIME_SENSITIVE &&
$sensitivity !== IJob::TIME_INSENSITIVE) {
throw new \InvalidArgumentException('Invalid sensitivity');
}
$this->timeSensitivity = $sensitivity;
}
/**
* Run the job if the last run is more than the interval ago
*
* @param IJobList $jobList
* @param ILogger|null $logger
*
* @since 15.0.0
* @deprecated since 25.0.0 Use start() instead
*/
final public function execute(IJobList $jobList, ILogger $logger = null) {
$this->start($jobList);
}
/**
* Run the job if the last run is more than the interval ago
*
* @since 25.0.0
*/
final public function start(IJobList $jobList): void {
if (($this->time->getTime() - $this->lastRun) > $this->interval) {
parent::start($jobList);
}
}
}