Differential D20614 Diff 49179 src/applications/files/management/PhabricatorFilesManagementCompactWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/management/PhabricatorFilesManagementCompactWorkflow.php
| <?php | <?php | ||||
| final class PhabricatorFilesManagementCompactWorkflow | final class PhabricatorFilesManagementCompactWorkflow | ||||
| extends PhabricatorFilesManagementWorkflow { | extends PhabricatorFilesManagementWorkflow { | ||||
| protected function didConstruct() { | protected function didConstruct() { | ||||
| $arguments = $this->newIteratorArguments(); | |||||
| $arguments[] = array( | |||||
| 'name' => 'dry-run', | |||||
| 'help' => pht('Show what would be compacted.'), | |||||
| ); | |||||
| $this | $this | ||||
| ->setName('compact') | ->setName('compact') | ||||
| ->setSynopsis( | ->setSynopsis( | ||||
| pht( | pht( | ||||
| 'Merge identical files to share the same storage. In some cases, '. | 'Merge identical files to share the same storage. In some cases, '. | ||||
| 'this can repair files with missing data.')) | 'this can repair files with missing data.')) | ||||
| ->setArguments( | ->setArguments($arguments); | ||||
| array( | |||||
| array( | |||||
| 'name' => 'dry-run', | |||||
| 'help' => pht('Show what would be compacted.'), | |||||
| ), | |||||
| array( | |||||
| 'name' => 'all', | |||||
| 'help' => pht('Compact all files.'), | |||||
| ), | |||||
| array( | |||||
| 'name' => 'names', | |||||
| 'wildcard' => true, | |||||
| ), | |||||
| )); | |||||
| } | } | ||||
| public function execute(PhutilArgumentParser $args) { | public function execute(PhutilArgumentParser $args) { | ||||
| $console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
| $iterator = $this->buildIterator($args); | $iterator = $this->buildIterator($args); | ||||
| if (!$iterator) { | |||||
| throw new PhutilArgumentUsageException( | |||||
| pht( | |||||
| 'Either specify a list of files to compact, or use `%s` '. | |||||
| 'to compact all files.', | |||||
| '--all')); | |||||
| } | |||||
| $is_dry_run = $args->getArg('dry-run'); | $is_dry_run = $args->getArg('dry-run'); | ||||
| foreach ($iterator as $file) { | foreach ($iterator as $file) { | ||||
| $monogram = $file->getMonogram(); | $monogram = $file->getMonogram(); | ||||
| $hash = $file->getContentHash(); | $hash = $file->getContentHash(); | ||||
| if (!$hash) { | if (!$hash) { | ||||
| $console->writeOut( | $console->writeOut( | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||