From 410f34d7fd8bbd8bb1be0c2ceadccd0779986ae2 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 23 Mar 2019 21:47:33 -0400 Subject: [PATCH 1/2] Add storage backend move cronjob - Fix typos in Console\Storage and Worker\CronJobs --- src/Core/Console/Storage.php | 2 +- src/Worker/CronJobs.php | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Core/Console/Storage.php b/src/Core/Console/Storage.php index ce89ce1e2c..805ef0aea9 100644 --- a/src/Core/Console/Storage.php +++ b/src/Core/Console/Storage.php @@ -84,7 +84,7 @@ HELP; if ($current === '') { $this->out(); - $this->out('This sistem is using legacy storage system'); + $this->out('This system is using legacy storage system'); } if ($current !== '' && !$isregisterd) { $this->out(); diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index 5ebe91cf40..d0f417f4ff 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -10,6 +10,8 @@ use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Logger; use Friendica\Core\Protocol; +use Friendica\Core\StorageManager; +use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Database\PostUpdate; use Friendica\Model\Contact; @@ -68,8 +70,12 @@ class CronJobs self::repairDatabase(); break; + case 'move_storage': + self::moveStorage(); + break; + default: - Logger::log("Xronjob " . $command . " is unknown.", Logger::DEBUG); + Logger::log("Cronjob " . $command . " is unknown.", Logger::DEBUG); } return; @@ -289,4 +295,20 @@ class CronJobs /// - remove children when parent got lost /// - set contact-id in item when not present } + + /** + * Moves up to 5000 attachments and photos to the current storage system. + * Self-replicates if legacy items have been found and moved. + * + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + */ + private static function moveStorage() + { + $current = StorageManager::getBackend(); + $moved = StorageManager::move($current); + + if ($moved) { + Worker::add(PRIORITY_LOW, "CronJobs", "move_storage"); + } + } } From 75380dab835955d50e125c0db45c5f21aa549070 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 23 Mar 2019 21:49:02 -0400 Subject: [PATCH 2/2] Added storage move cronjob to CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 87f4f818c8..0e4a2616e5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ Version 2019.06 (UNRELEASED) (2019-06-?) General Code cleaning and restructuring [nupplaphil] Added frio color scheme sharing [JeroenED] Added syslog and stream Logger [nupplaphil] + Added storage move cronjob [MrPetovan] Closed Issues: 6303, 6478, 6319