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,91 @@
<?php
declare(strict_types=1);
/**
* @copyright 2018 Morris Jobke <hey@morrisjobke.de>
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @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 OC\Core\BackgroundJobs;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
use OCP\IConfig;
use Psr\Log\LoggerInterface;
class BackgroundCleanupUpdaterBackupsJob extends QueuedJob {
public function __construct(
protected IConfig $config,
protected LoggerInterface $log,
ITimeFactory $time,
) {
parent::__construct($time);
}
/**
* This job cleans up all backups except the latest 3 from the updaters backup directory
*/
public function run($arguments) {
$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)) {
return;
}
$updaterFolderPath = $updateDir . '/updater-' . $instanceId;
$backupFolderPath = $updaterFolderPath . '/backups';
if (file_exists($backupFolderPath)) {
$this->log->info("$backupFolderPath exists - start to clean it up");
$dirList = [];
$dirs = new \DirectoryIterator($backupFolderPath);
foreach ($dirs as $dir) {
// skip files and dot dirs
if ($dir->isFile() || $dir->isDot()) {
continue;
}
$mtime = $dir->getMTime();
$realPath = $dir->getRealPath();
if ($realPath === false) {
continue;
}
$dirList[$mtime] = $realPath;
}
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));
foreach ($dirList as $dir) {
$this->log->info("Removing $dir ...");
\OC_Helper::rmdirr($dir);
}
$this->log->info("Cleanup finished");
} else {
$this->log->info("Could not find updater directory $backupFolderPath - cleanup step not needed");
}
}
}
@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
/**
* @copyright 2020 Morris Jobke <hey@morrisjobke.de>
*
* @author J0WI <J0WI@users.noreply.github.com>
* @author Morris Jobke <hey@morrisjobke.de>
*
* @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 OC\Core\BackgroundJobs;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
class CheckForUserCertificates extends QueuedJob {
public function __construct(
protected IConfig $config,
private IUserManager $userManager,
private IRootFolder $rootFolder,
ITimeFactory $time,
) {
parent::__construct($time);
}
/**
* Checks all user directories for old user uploaded certificates
*/
public function run($arguments): void {
$uploadList = [];
$this->userManager->callForSeenUsers(function (IUser $user) use (&$uploadList) {
$userId = $user->getUID();
try {
\OC_Util::setupFS($userId);
$filesExternalUploadsFolder = $this->rootFolder->get($userId . '/files_external/uploads');
} catch (NotFoundException $e) {
\OC_Util::tearDownFS();
return;
}
if ($filesExternalUploadsFolder instanceof Folder) {
$files = $filesExternalUploadsFolder->getDirectoryListing();
foreach ($files as $file) {
$filename = $file->getName();
$uploadList[] = "$userId/files_external/uploads/$filename";
}
}
\OC_Util::tearDownFS();
});
if (empty($uploadList)) {
$this->config->deleteAppValue('files_external', 'user_certificate_scan');
} else {
$this->config->setAppValue('files_external', 'user_certificate_scan', json_encode($uploadList));
}
}
}
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author J0WI <J0WI@users.noreply.github.com>
* @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 OC\Core\BackgroundJobs;
use OC\Core\Db\LoginFlowV2Mapper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
class CleanupLoginFlowV2 extends TimedJob {
public function __construct(
ITimeFactory $time,
private LoginFlowV2Mapper $loginFlowV2Mapper,
) {
parent::__construct($time);
$this->setInterval(3600);
}
protected function run($argument): void {
$this->loginFlowV2Mapper->cleanup();
}
}
@@ -0,0 +1,117 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2023 Louis Chemineau <louis@chmn.me>
*
* @author Louis Chemineau <louis@chmn.me>
*
* @license AGPL-3.0-or-later
*
* 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 OC\Core\BackgroundJobs;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\TimedJob;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\FilesMetadata\Exceptions\FilesMetadataNotFoundException;
use OCP\FilesMetadata\IFilesMetadataManager;
use OCP\IConfig;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
class GenerateMetadataJob extends TimedJob {
public function __construct(
ITimeFactory $time,
private IConfig $config,
private IRootFolder $rootFolder,
private IUserManager $userManager,
private IFilesMetadataManager $filesMetadataManager,
private IJobList $jobList,
private LoggerInterface $logger,
) {
parent::__construct($time);
$this->setTimeSensitivity(\OCP\BackgroundJob\IJob::TIME_INSENSITIVE);
$this->setInterval(24 * 3600);
}
protected function run(mixed $argument): void {
$users = $this->userManager->search('');
$lastHandledUser = $this->config->getAppValue('core', 'metadataGenerationLastHandledUser', '');
// we'll only start timer once we have found a valid user to handle
// meaning NOW if we have not handled any user from a previous run
$startTime = ($lastHandledUser === '') ? time() : null;
foreach ($users as $user) {
$userId = $user->getUID();
// if we already handled a previous run, we start timer only when we face the last handled user
if ($startTime === null) {
if ($userId === $lastHandledUser) {
$startTime = time();
}
continue;
}
$this->config->setAppValue('core', 'metadataGenerationLastHandledUser', $userId);
$this->scanFilesForUser($user->getUID());
// Stop if execution time is more than one hour.
if (time() - $startTime > 3600) {
return;
}
}
$this->jobList->remove(GenerateMetadataJob::class);
$this->config->deleteAppValue('core', 'metadataGenerationLastHandledUser');
}
private function scanFilesForUser(string $userId): void {
$userFolder = $this->rootFolder->getUserFolder($userId);
$this->scanFolder($userFolder);
}
private function scanFolder(Folder $folder): void {
// Do not scan share and other moveable mounts.
if ($folder->getMountPoint() instanceof \OC\Files\Mount\MoveableMount) {
return;
}
foreach ($folder->getDirectoryListing() as $node) {
if ($node instanceof Folder) {
$this->scanFolder($node);
continue;
}
try {
$this->filesMetadataManager->getMetadata($node->getId(), false);
} catch (FilesMetadataNotFoundException) {
try {
$this->filesMetadataManager->refreshMetadata(
$node,
IFilesMetadataManager::PROCESS_LIVE | IFilesMetadataManager::PROCESS_BACKGROUND
);
} catch (\Throwable $ex) {
$this->logger->warning("Error while generating metadata for fileid " . $node->getId(), ['exception' => $ex]);
}
}
}
}
}
@@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 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 OC\Core\BackgroundJobs;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\QueuedJob;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
class LookupServerSendCheckBackgroundJob extends QueuedJob {
public function __construct(
protected IConfig $config,
private IUserManager $userManager,
ITimeFactory $time,
) {
parent::__construct($time);
}
public function run($arguments) {
$this->userManager->callForSeenUsers(function (IUser $user) {
$this->config->setUserValue($user->getUID(), 'lookup_server_connector', 'dataSend', '1');
});
}
}