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,54 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2016 Julius Härtl <jus@bitgrid.net>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Julius Härtl <jus@bitgrid.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 OCA\Files\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\DirectEditing\IManager;
class CleanupDirectEditingTokens extends TimedJob {
private const INTERVAL_MINUTES = 15 * 60;
private IManager $manager;
public function __construct(ITimeFactory $time,
IManager $manager) {
parent::__construct($time);
$this->interval = self::INTERVAL_MINUTES;
$this->manager = $manager;
}
/**
* Makes the background job do its work
*
* @param array $argument unused argument
* @throws \Exception
*/
public function run($argument) {
$this->manager->cleanup();
}
}
@@ -0,0 +1,62 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Max Kovalenko <mxss1998@yandex.ru>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @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 OCA\Files\BackgroundJob;
use OC\Lock\DBLockingProvider;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
/**
* Clean up all file locks that are expired for the DB file locking provider
*/
class CleanupFileLocks extends TimedJob {
/**
* Default interval in minutes
*
* @var int $defaultIntervalMin
**/
protected $defaultIntervalMin = 5;
/**
* sets the correct interval for this timed job
*/
public function __construct(ITimeFactory $time) {
parent::__construct($time);
$this->interval = $this->defaultIntervalMin * 60;
}
/**
* Makes the background job do its work
*
* @param array $argument unused argument
* @throws \Exception
*/
public function run($argument) {
$lockingProvider = \OC::$server->getLockingProvider();
if ($lockingProvider instanceof DBLockingProvider) {
$lockingProvider->cleanExpiredLocks();
}
}
}
@@ -0,0 +1,60 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com>
*
* @author Joas Schilling <coding@schilljs.com>
*
* @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 OCA\Files\BackgroundJob;
use OCA\Files\Db\OpenLocalEditorMapper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJob;
use OCP\BackgroundJob\TimedJob;
/**
* Delete all expired "Open local editor" token
*/
class DeleteExpiredOpenLocalEditor extends TimedJob {
protected OpenLocalEditorMapper $mapper;
public function __construct(
ITimeFactory $time,
OpenLocalEditorMapper $mapper
) {
parent::__construct($time);
$this->mapper = $mapper;
// Run every 12h
$this->interval = 12 * 3600;
$this->setTimeSensitivity(IJob::TIME_INSENSITIVE);
}
/**
* Makes the background job do its work
*
* @param array $argument unused argument
*/
public function run($argument): void {
$this->mapper->deleteExpiredTokens($this->time->getTime());
}
}
@@ -0,0 +1,146 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Joas Schilling <coding@schilljs.com>
* @author Vincent Petry <vincent@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 OCA\Files\BackgroundJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use Psr\Log\LoggerInterface;
/**
* Delete all share entries that have no matching entries in the file cache table.
*/
class DeleteOrphanedItems extends TimedJob {
public const CHUNK_SIZE = 200;
protected $defaultIntervalMin = 60;
/**
* sets the correct interval for this timed job
*/
public function __construct(
ITimeFactory $time,
protected IDBConnection $connection,
protected LoggerInterface $logger,
) {
parent::__construct($time);
$this->interval = $this->defaultIntervalMin * 60;
}
/**
* Makes the background job do its work
*
* @param array $argument unused argument
*/
public function run($argument) {
$this->cleanSystemTags();
$this->cleanUserTags();
$this->cleanComments();
$this->cleanCommentMarkers();
}
/**
* Deleting orphaned system tag mappings
*
* @param string $table
* @param string $idCol
* @param string $typeCol
* @return int Number of deleted entries
*/
protected function cleanUp($table, $idCol, $typeCol) {
$deletedEntries = 0;
$query = $this->connection->getQueryBuilder();
$query->select('t1.' . $idCol)
->from($table, 't1')
->where($query->expr()->eq($typeCol, $query->expr()->literal('files')))
->andWhere($query->expr()->isNull('t2.fileid'))
->leftJoin('t1', 'filecache', 't2', $query->expr()->eq($query->expr()->castColumn('t1.' . $idCol, IQueryBuilder::PARAM_INT), 't2.fileid'))
->groupBy('t1.' . $idCol)
->setMaxResults(self::CHUNK_SIZE);
$deleteQuery = $this->connection->getQueryBuilder();
$deleteQuery->delete($table)
->where($deleteQuery->expr()->eq($idCol, $deleteQuery->createParameter('objectid')));
$deletedInLastChunk = self::CHUNK_SIZE;
while ($deletedInLastChunk === self::CHUNK_SIZE) {
$result = $query->execute();
$deletedInLastChunk = 0;
while ($row = $result->fetch()) {
$deletedInLastChunk++;
$deletedEntries += $deleteQuery->setParameter('objectid', (int) $row[$idCol])
->execute();
}
$result->closeCursor();
}
return $deletedEntries;
}
/**
* Deleting orphaned system tag mappings
*
* @return int Number of deleted entries
*/
protected function cleanSystemTags() {
$deletedEntries = $this->cleanUp('systemtag_object_mapping', 'objectid', 'objecttype');
$this->logger->debug("$deletedEntries orphaned system tag relations deleted", ['app' => 'DeleteOrphanedItems']);
return $deletedEntries;
}
/**
* Deleting orphaned user tag mappings
*
* @return int Number of deleted entries
*/
protected function cleanUserTags() {
$deletedEntries = $this->cleanUp('vcategory_to_object', 'objid', 'type');
$this->logger->debug("$deletedEntries orphaned user tag relations deleted", ['app' => 'DeleteOrphanedItems']);
return $deletedEntries;
}
/**
* Deleting orphaned comments
*
* @return int Number of deleted entries
*/
protected function cleanComments() {
$deletedEntries = $this->cleanUp('comments', 'object_id', 'object_type');
$this->logger->debug("$deletedEntries orphaned comments deleted", ['app' => 'DeleteOrphanedItems']);
return $deletedEntries;
}
/**
* Deleting orphaned comment read markers
*
* @return int Number of deleted entries
*/
protected function cleanCommentMarkers() {
$deletedEntries = $this->cleanUp('comments_read_markers', 'object_id', 'object_type');
$this->logger->debug("$deletedEntries orphaned comment read marks deleted", ['app' => 'DeleteOrphanedItems']);
return $deletedEntries;
}
}
@@ -0,0 +1,123 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Lukas Reschke <lukas@statuscode.ch>
* @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 OCA\Files\BackgroundJob;
use OC\Files\Utils\Scanner;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IConfig;
use OCP\IDBConnection;
use Psr\Log\LoggerInterface;
/**
* Class ScanFiles is a background job used to run the file scanner over the user
* accounts to ensure integrity of the file cache.
*
* @package OCA\Files\BackgroundJob
*/
class ScanFiles extends TimedJob {
private IConfig $config;
private IEventDispatcher $dispatcher;
private LoggerInterface $logger;
private IDBConnection $connection;
/** Amount of users that should get scanned per execution */
public const USERS_PER_SESSION = 500;
public function __construct(
IConfig $config,
IEventDispatcher $dispatcher,
LoggerInterface $logger,
IDBConnection $connection,
ITimeFactory $time
) {
parent::__construct($time);
// Run once per 10 minutes
$this->setInterval(60 * 10);
$this->config = $config;
$this->dispatcher = $dispatcher;
$this->logger = $logger;
$this->connection = $connection;
}
protected function runScanner(string $user): void {
try {
$scanner = new Scanner(
$user,
null,
$this->dispatcher,
$this->logger
);
$scanner->backgroundScan('');
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), ['exception' => $e, 'app' => 'files']);
}
\OC_Util::tearDownFS();
}
/**
* Find a storage which have unindexed files and return a user with access to the storage
*
* @return string|false
*/
private function getUserToScan() {
$query = $this->connection->getQueryBuilder();
$query->select('user_id')
->from('filecache', 'f')
->innerJoin('f', 'mounts', 'm', $query->expr()->eq('storage_id', 'storage'))
->where($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->gt('parent', $query->createNamedParameter(-1, IQueryBuilder::PARAM_INT)))
->setMaxResults(1);
return $query->executeQuery()->fetchOne();
}
/**
* @param $argument
* @throws \Exception
*/
protected function run($argument) {
if ($this->config->getSystemValueBool('files_no_background_scan', false)) {
return;
}
$usersScanned = 0;
$lastUser = '';
$user = $this->getUserToScan();
while ($user && $usersScanned < self::USERS_PER_SESSION && $lastUser !== $user) {
$this->runScanner($user);
$lastUser = $user;
$user = $this->getUserToScan();
$usersScanned += 1;
}
if ($lastUser === $user) {
$this->logger->warning("User $user still has unscanned files after running background scan, background scan might be stopped prematurely");
}
}
}
@@ -0,0 +1,162 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, 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 OCA\Files\BackgroundJob;
use OCA\Files\AppInfo\Application;
use OCA\Files\Db\TransferOwnership as Transfer;
use OCA\Files\Db\TransferOwnershipMapper;
use OCA\Files\Exception\TransferOwnershipException;
use OCA\Files\Service\OwnershipTransferService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
use OCP\Files\IRootFolder;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Notification\IManager as NotificationManager;
use Psr\Log\LoggerInterface;
use function ltrim;
class TransferOwnership extends QueuedJob {
public function __construct(
ITimeFactory $timeFactory,
private IUserManager $userManager,
private OwnershipTransferService $transferService,
private LoggerInterface $logger,
private NotificationManager $notificationManager,
private TransferOwnershipMapper $mapper,
private IRootFolder $rootFolder,
) {
parent::__construct($timeFactory);
}
protected function run($argument) {
$id = $argument['id'];
$transfer = $this->mapper->getById($id);
$sourceUser = $transfer->getSourceUser();
$destinationUser = $transfer->getTargetUser();
$fileId = $transfer->getFileId();
$userFolder = $this->rootFolder->getUserFolder($sourceUser);
$nodes = $userFolder->getById($fileId);
if (empty($nodes)) {
$this->logger->alert('Could not transfer ownership: Node not found');
$this->failedNotication($transfer);
return;
}
$path = $userFolder->getRelativePath($nodes[0]->getPath());
$sourceUserObject = $this->userManager->get($sourceUser);
$destinationUserObject = $this->userManager->get($destinationUser);
if (!$sourceUserObject instanceof IUser) {
$this->logger->alert('Could not transfer ownership: Unknown source user ' . $sourceUser);
$this->failedNotication($transfer);
return;
}
if (!$destinationUserObject instanceof IUser) {
$this->logger->alert("Unknown destination user $destinationUser");
$this->failedNotication($transfer);
return;
}
try {
$this->transferService->transfer(
$sourceUserObject,
$destinationUserObject,
ltrim($path, '/')
);
$this->successNotification($transfer);
} catch (TransferOwnershipException $e) {
$this->logger->error(
$e->getMessage(),
[
'exception' => $e,
],
);
$this->failedNotication($transfer);
}
$this->mapper->delete($transfer);
}
private function failedNotication(Transfer $transfer): void {
// Send notification to source user
$notification = $this->notificationManager->createNotification();
$notification->setUser($transfer->getSourceUser())
->setApp(Application::APP_ID)
->setDateTime($this->time->getDateTime())
->setSubject('transferOwnershipFailedSource', [
'sourceUser' => $transfer->getSourceUser(),
'targetUser' => $transfer->getTargetUser(),
'nodeName' => $transfer->getNodeName(),
])
->setObject('transfer', (string)$transfer->getId());
$this->notificationManager->notify($notification);
// Send notification to source user
$notification = $this->notificationManager->createNotification();
$notification->setUser($transfer->getTargetUser())
->setApp(Application::APP_ID)
->setDateTime($this->time->getDateTime())
->setSubject('transferOwnershipFailedTarget', [
'sourceUser' => $transfer->getSourceUser(),
'targetUser' => $transfer->getTargetUser(),
'nodeName' => $transfer->getNodeName(),
])
->setObject('transfer', (string)$transfer->getId());
$this->notificationManager->notify($notification);
}
private function successNotification(Transfer $transfer): void {
// Send notification to source user
$notification = $this->notificationManager->createNotification();
$notification->setUser($transfer->getSourceUser())
->setApp(Application::APP_ID)
->setDateTime($this->time->getDateTime())
->setSubject('transferOwnershipDoneSource', [
'sourceUser' => $transfer->getSourceUser(),
'targetUser' => $transfer->getTargetUser(),
'nodeName' => $transfer->getNodeName(),
])
->setObject('transfer', (string)$transfer->getId());
$this->notificationManager->notify($notification);
// Send notification to source user
$notification = $this->notificationManager->createNotification();
$notification->setUser($transfer->getTargetUser())
->setApp(Application::APP_ID)
->setDateTime($this->time->getDateTime())
->setSubject('transferOwnershipDoneTarget', [
'sourceUser' => $transfer->getSourceUser(),
'targetUser' => $transfer->getTargetUser(),
'nodeName' => $transfer->getNodeName(),
])
->setObject('transfer', (string)$transfer->getId());
$this->notificationManager->notify($notification);
}
}