sforkowany z mirror/friendica
Fix handling table name during storage move
rodzic
c079a35397
commit
16ff5af221
|
@ -112,19 +112,21 @@ HELP;
|
||||||
|
|
||||||
protected function do_move()
|
protected function do_move()
|
||||||
{
|
{
|
||||||
$table = null;
|
$tables = null;
|
||||||
if (count($this->args) < 1 || count($this->args) > 2) {
|
if (count($this->args) < 1 || count($this->args) > 2) {
|
||||||
throw new CommandArgsException('Invalid arguments');
|
throw new CommandArgsException('Invalid arguments');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->args) == 2) {
|
if (count($this->args) == 2) {
|
||||||
$table = strtolower($this->args[1]);
|
$table = strtolower($this->args[1]);
|
||||||
if (!in_array($table, ['photo', 'attach'])) {
|
if (!in_array($table, ['photo', 'attach'])) {
|
||||||
throw new CommandArgsException('Invalid table');
|
throw new CommandArgsException('Invalid table');
|
||||||
}
|
}
|
||||||
|
$tables = [$table];
|
||||||
}
|
}
|
||||||
|
|
||||||
$current = StorageManager::getBackend();
|
$current = StorageManager::getBackend();
|
||||||
$r = StorageManager::move($current);
|
$r = StorageManager::move($current, $tables);
|
||||||
$this->out(sprintf('Moved %d files', $r));
|
$this->out(sprintf('Moved %d files', $r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,8 @@ class StorageManager
|
||||||
* Copy existing data to destination storage and delete from source.
|
* Copy existing data to destination storage and delete from source.
|
||||||
* This method cannot move to legacy in-table `data` field.
|
* This method cannot move to legacy in-table `data` field.
|
||||||
*
|
*
|
||||||
* @param string $dest Destination storage class name
|
* @param string $dest Destination storage class name
|
||||||
* @param array $tables Tables to look in for resources. Optional, defaults to ['photo', 'attach']
|
* @param array|null $tables Tables to look in for resources. Optional, defaults to ['photo', 'attach']
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @return int Number of moved resources
|
* @return int Number of moved resources
|
||||||
|
|
Ładowanie…
Reference in New Issue