Differential D20614 Diff 49179 src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
| <?php | <?php | ||||
| final class PhabricatorFilesManagementMigrateWorkflow | final class PhabricatorFilesManagementMigrateWorkflow | ||||
| extends PhabricatorFilesManagementWorkflow { | extends PhabricatorFilesManagementWorkflow { | ||||
| protected function didConstruct() { | protected function didConstruct() { | ||||
| $this | $arguments = $this->newIteratorArguments(); | ||||
| ->setName('migrate') | |||||
| ->setSynopsis(pht('Migrate files between storage engines.')) | $arguments[] = array( | ||||
| ->setArguments( | |||||
| array( | |||||
| array( | |||||
| 'name' => 'engine', | 'name' => 'engine', | ||||
| 'param' => 'storage_engine', | 'param' => 'storage-engine', | ||||
| 'help' => pht('Migrate to the named storage engine.'), | 'help' => pht('Migrate to the named storage engine.'), | ||||
| ), | ); | ||||
| array( | |||||
| $arguments[] = array( | |||||
| 'name' => 'dry-run', | 'name' => 'dry-run', | ||||
| 'help' => pht('Show what would be migrated.'), | 'help' => pht('Show what would be migrated.'), | ||||
| ), | ); | ||||
| array( | |||||
| $arguments[] = array( | |||||
| 'name' => 'min-size', | 'name' => 'min-size', | ||||
| 'param' => 'bytes', | 'param' => 'bytes', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Do not migrate data for files which are smaller than a given '. | 'Do not migrate data for files which are smaller than a given '. | ||||
| 'filesize.'), | 'filesize.'), | ||||
| ), | ); | ||||
| array( | |||||
| $arguments[] = array( | |||||
| 'name' => 'max-size', | 'name' => 'max-size', | ||||
| 'param' => 'bytes', | 'param' => 'bytes', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Do not migrate data for files which are larger than a given '. | 'Do not migrate data for files which are larger than a given '. | ||||
| 'filesize.'), | 'filesize.'), | ||||
| ), | ); | ||||
| array( | |||||
| 'name' => 'all', | $arguments[] = array( | ||||
| 'help' => pht('Migrate all files.'), | |||||
| ), | |||||
| array( | |||||
| 'name' => 'copy', | 'name' => 'copy', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Copy file data instead of moving it: after migrating, do not '. | 'Copy file data instead of moving it: after migrating, do not '. | ||||
| 'remove the old data even if it is no longer referenced.'), | 'remove the old data even if it is no longer referenced.'), | ||||
| ), | ); | ||||
| array( | |||||
| 'name' => 'names', | $arguments[] = array( | ||||
| 'wildcard' => true, | |||||
| ), | |||||
| array( | |||||
| 'name' => 'from-engine', | |||||
| 'param' => 'engine', | |||||
| 'help' => pht('Migrate files from the named storage engine.'), | |||||
| ), | |||||
| array( | |||||
| 'name' => 'local-disk-source', | 'name' => 'local-disk-source', | ||||
| 'param' => 'path', | 'param' => 'path', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'When migrating from a local disk source, use the specified '. | 'When migrating from a local disk source, use the specified '. | ||||
| 'path as the root directory.'), | 'path as the root directory.'), | ||||
| ), | ); | ||||
| )); | |||||
| $this | |||||
| ->setName('migrate') | |||||
| ->setSynopsis(pht('Migrate files between storage engines.')) | |||||
| ->setArguments($arguments); | |||||
| } | } | ||||
| public function execute(PhutilArgumentParser $args) { | public function execute(PhutilArgumentParser $args) { | ||||
| // See T13306. This flag allows you to import files from a backup of | // See T13306. This flag allows you to import files from a backup of | ||||
| // local disk storage into some other engine. When the caller provides | // local disk storage into some other engine. When the caller provides | ||||
| // the flag, we override the local disk engine configuration and treat | // the flag, we override the local disk engine configuration and treat | ||||
| // it as though it is configured to use the specified location. | // it as though it is configured to use the specified location. | ||||
| Show All 22 Lines | if (!$target_key) { | ||||
| 'Use `%s` to get a list of engines.', | 'Use `%s` to get a list of engines.', | ||||
| '--engine', | '--engine', | ||||
| 'files engines')); | 'files engines')); | ||||
| } | } | ||||
| $target_engine = PhabricatorFile::buildEngine($target_key); | $target_engine = PhabricatorFile::buildEngine($target_key); | ||||
| $iterator = $this->buildIterator($args); | $iterator = $this->buildIterator($args); | ||||
| if (!$iterator) { | |||||
| throw new PhutilArgumentUsageException( | |||||
| pht( | |||||
| 'Either specify a list of files to migrate, or use `%s` '. | |||||
| 'to migrate all files.', | |||||
| '--all')); | |||||
| } | |||||
| $is_dry_run = $args->getArg('dry-run'); | $is_dry_run = $args->getArg('dry-run'); | ||||
| $min_size = (int)$args->getArg('min-size'); | $min_size = (int)$args->getArg('min-size'); | ||||
| $max_size = (int)$args->getArg('max-size'); | $max_size = (int)$args->getArg('max-size'); | ||||
| $is_copy = $args->getArg('copy'); | $is_copy = $args->getArg('copy'); | ||||
| $failed = array(); | $failed = array(); | ||||
| ▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines | |||||