Differential D20614 Diff 49179 src/applications/files/management/PhabricatorFilesManagementWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/management/PhabricatorFilesManagementWorkflow.php
| <?php | <?php | ||||
| abstract class PhabricatorFilesManagementWorkflow | abstract class PhabricatorFilesManagementWorkflow | ||||
| extends PhabricatorManagementWorkflow { | extends PhabricatorManagementWorkflow { | ||||
| protected function newIteratorArguments() { | |||||
| return array( | |||||
| array( | |||||
| 'name' => 'all', | |||||
| 'help' => pht('Operate on all files.'), | |||||
| ), | |||||
| array( | |||||
| 'name' => 'names', | |||||
| 'wildcard' => true, | |||||
| ), | |||||
| array( | |||||
| 'name' => 'from-engine', | |||||
| 'param' => 'storage-engine', | |||||
| 'help' => pht('Operate on files stored in a specified engine.'), | |||||
| ), | |||||
| ); | |||||
| } | |||||
| protected function buildIterator(PhutilArgumentParser $args) { | protected function buildIterator(PhutilArgumentParser $args) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $names = $args->getArg('names'); | |||||
| $is_all = $args->getArg('all'); | $is_all = $args->getArg('all'); | ||||
| $names = $args->getArg('names'); | |||||
| $from_engine = $args->getArg('from-engine'); | $from_engine = $args->getArg('from-engine'); | ||||
| $any_constraint = ($from_engine || $names); | $any_constraint = ($from_engine || $names); | ||||
| if (!$is_all && !$any_constraint) { | if (!$is_all && !$any_constraint) { | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht( | pht( | ||||
| 'Use "--all" to migrate all files, or choose files to migrate '. | 'Specify which files to operate on, or use "--all" to operate on '. | ||||
| 'with "--names" or "--from-engine".')); | 'all files.')); | ||||
| } | } | ||||
| if ($is_all && $any_constraint) { | if ($is_all && $any_constraint) { | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht( | pht( | ||||
| 'You can not migrate all files with "--all" and also migrate only '. | 'You can not operate on all files with "--all" and also operate '. | ||||
| 'a subset of files with "--from-engine" or "--names".')); | 'on a subset of files by naming them explicitly or using '. | ||||
| 'constraint flags like "--from-engine".')); | |||||
| } | } | ||||
| // If we're migrating specific named files, convert the names into IDs | // If we're migrating specific named files, convert the names into IDs | ||||
| // first. | // first. | ||||
| $ids = null; | $ids = null; | ||||
| if ($names) { | if ($names) { | ||||
| $files = $this->loadFilesWithNames($names); | $files = $this->loadFilesWithNames($names); | ||||
| $ids = mpull($files, 'getID'); | $ids = mpull($files, 'getID'); | ||||
| Show All 38 Lines | |||||