]> git.mxchange.org Git - friendica.git/commitdiff
Update "storage" console command
authorfabrixxm <fabrix.xm@gmail.com>
Thu, 3 Jan 2019 21:35:46 +0000 (22:35 +0100)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 21 Jan 2019 15:00:48 +0000 (10:00 -0500)
add support to move data in 'attach' table

src/Core/Console/Storage.php
src/Core/StorageManager.php
src/Model/Attach.php

index 9334824e355c5e7aa13836bc785c270345fa8cf8..601019fa8bb03a62e8203d09d7035c1995798129 100644 (file)
@@ -19,9 +19,18 @@ class Storage extends \Asika\SimpleConsole\Console
 console storage - manage storage backend and stored data
 Synopsis
     bin/console storage [-h|--help|-?] [-v]
+        Show this help
+    
     bin/console storage list
+        List avaiable storage backends
+    
     bin/console storage set <name>
-    bin/console storage move
+        Set current storage backend
+            name        storage backend to use. see "list".
+    
+    bin/console storage move [table]
+        Move stored data to current storage backend.
+            table       one of "photo" or "attach". default to both
 HELP;
                return $help;
        }
@@ -105,9 +114,16 @@ HELP;
 
        protected function do_move()
        {
-               if (count($this->args) !== 1) {
+               $table = null;
+               if (count($this->args) < 1 || count($this->args) > 2) {
                        throw new CommandArgsException('Invalid arguments');
                }
+               if (count($this->args) == 2) {
+                       $table = strtolower($this->args[1]);
+                       if (!in_array($table, ['photo', 'attach'])) {
+                               throw new CommandArgsException('Invalid table');
+                       }
+               }
 
                $current = StorageManager::getBackend();
                $r = StorageManager::move($current);
index 8dd7654e60eac02b3d24697b297044fc7dc455fb..43a72650cc821b967967077d4233e07a79c26daf 100644 (file)
@@ -110,7 +110,7 @@ class StorageManager
         * This method cannot move to legacy in-table `data` field.
         *
         * @param string  $dest    Destination storage class name
-        * @param array   $tables  Tables to look in for resources. Optional, defaults to ['photo']
+        * @param array   $tables  Tables to look in for resources. Optional, defaults to ['photo', 'attach']
         *
         * @retur int Number of moved resources
         */
@@ -121,7 +121,7 @@ class StorageManager
                }
                
                if (is_null($tables)) {
-                       $tables = ['photo'];
+                       $tables = ['photo', 'attach'];
                }
 
                $moved = 0;
index 48b034e4992d7a20f76fd04dd3170414234e2afe..92c76d3d0ac9a2e17e9b5d82e9fc0ce28005a44b 100644 (file)
@@ -224,7 +224,7 @@ class Attach extends BaseObject
 
                $data = @file_get_contents($src);
 
-               return  self::store($data, $uid, $filename, '', null, $allow_cid, $allow_gid,  $deny_cid, $deny_gid);
+               return self::store($data, $uid, $filename, '', null, $allow_cid, $allow_gid,  $deny_cid, $deny_gid);
        }