]> git.mxchange.org Git - friendica.git/commitdiff
Add storage backend move cronjob
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 24 Mar 2019 01:47:33 +0000 (21:47 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 24 Mar 2019 01:47:33 +0000 (21:47 -0400)
- Fix typos in Console\Storage and Worker\CronJobs

src/Core/Console/Storage.php
src/Worker/CronJobs.php

index ce89ce1e2cb7e469571d14e6c9b3a3146e8a2aa4..805ef0aea9ef7e5d6d5f361e5f0288e42d04a924 100644 (file)
@@ -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();
index 5ebe91cf406229811841f375d0397e0b113a2a37..d0f417f4ffd0c530f561f61f63c89c0df9231e07 100644 (file)
@@ -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");
+               }
+       }
 }