]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Console/Storage.php
Improved protocol storing
[friendica.git] / src / Core / Console / Storage.php
index a7a0ffd38b34a7183b47c3b2f53d3e4e893238b3..805ef0aea9ef7e5d6d5f361e5f0288e42d04a924 100644 (file)
@@ -28,9 +28,10 @@ Synopsis
         Set current storage backend
             name        storage backend to use. see "list".
     
-    bin/console storage move [table]
+    bin/console storage move [table] [-n 5000]
         Move stored data to current storage backend.
             table       one of "photo" or "attach". default to both
+            -n          limit of processed entry batch size
 HELP;
                return $help;
        }
@@ -83,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();
@@ -106,7 +107,11 @@ HELP;
                        return -1;
                }
 
-               StorageManager::setBackend($class);
+               if (!StorageManager::setBackend($class)) {
+                       $this->out($class . ' is not a valid backend storage class.');
+                       return -1;
+               }
+
                return 0;
        }
 
@@ -126,7 +131,17 @@ HELP;
                }
 
                $current = StorageManager::getBackend();
-               $r = StorageManager::move($current, $tables);
-               $this->out(sprintf('Moved %d files', $r));
+               $total = 0;
+
+               do {
+                       $moved = StorageManager::move($current, $tables, $this->getOption('n', 5000));
+                       if ($moved) {
+                               $this->out(date('[Y-m-d H:i:s] ') . sprintf('Moved %d files', $moved));
+                       }
+
+                       $total += $moved;
+               } while ($moved);
+
+               $this->out(sprintf(date('[Y-m-d H:i:s] ') . 'Moved %d files total', $total));
        }
 }