Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15312157
D20614.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
17 KB
Referenced Files
None
Subscribers
None
D20614.diff
View Options
diff --git a/src/applications/files/management/PhabricatorFilesManagementCompactWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementCompactWorkflow.php
--- a/src/applications/files/management/PhabricatorFilesManagementCompactWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementCompactWorkflow.php
@@ -4,41 +4,25 @@
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
+ $arguments = $this->newIteratorArguments();
+ $arguments[] = array(
+ 'name' => 'dry-run',
+ 'help' => pht('Show what would be compacted.'),
+ );
+
$this
->setName('compact')
->setSynopsis(
pht(
'Merge identical files to share the same storage. In some cases, '.
'this can repair files with missing data.'))
- ->setArguments(
- 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,
- ),
- ));
+ ->setArguments($arguments);
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
$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');
foreach ($iterator as $file) {
diff --git a/src/applications/files/management/PhabricatorFilesManagementCycleWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementCycleWorkflow.php
--- a/src/applications/files/management/PhabricatorFilesManagementCycleWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementCycleWorkflow.php
@@ -4,36 +4,22 @@
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
+ $arguments = $this->newIteratorArguments();
+ $arguments[] = array(
+ 'name' => 'key',
+ 'param' => 'keyname',
+ 'help' => pht('Select a specific storage key to cycle to.'),
+ );
+
$this
->setName('cycle')
->setSynopsis(
pht('Cycle master key for encrypted files.'))
- ->setArguments(
- array(
- array(
- 'name' => 'key',
- 'param' => 'keyname',
- 'help' => pht('Select a specific storage key to cycle to.'),
- ),
- array(
- 'name' => 'all',
- 'help' => pht('Change encoding for all files.'),
- ),
- array(
- 'name' => 'names',
- 'wildcard' => true,
- ),
- ));
+ ->setArguments($arguments);
}
public function execute(PhutilArgumentParser $args) {
$iterator = $this->buildIterator($args);
- if (!$iterator) {
- throw new PhutilArgumentUsageException(
- pht(
- 'Either specify a list of files to cycle, or use --all to cycle '.
- 'all files.'));
- }
$format_map = PhabricatorFileStorageFormat::getAllFormats();
$engines = PhabricatorFileStorageEngine::loadAllEngines();
diff --git a/src/applications/files/management/PhabricatorFilesManagementEncodeWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementEncodeWorkflow.php
--- a/src/applications/files/management/PhabricatorFilesManagementEncodeWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementEncodeWorkflow.php
@@ -4,47 +4,36 @@
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
+ $arguments = $this->newIteratorArguments();
+
+ $arguments[] = array(
+ 'name' => 'as',
+ 'param' => 'format',
+ 'help' => pht('Select the storage format to use.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'key',
+ 'param' => 'keyname',
+ 'help' => pht('Select a specific storage key.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'force',
+ 'help' => pht(
+ 'Re-encode files which are already stored in the target '.
+ 'encoding.'),
+ );
+
$this
->setName('encode')
->setSynopsis(
pht('Change the storage encoding of files.'))
- ->setArguments(
- array(
- array(
- 'name' => 'as',
- 'param' => 'format',
- 'help' => pht('Select the storage format to use.'),
- ),
- array(
- 'name' => 'key',
- 'param' => 'keyname',
- 'help' => pht('Select a specific storage key.'),
- ),
- array(
- 'name' => 'all',
- 'help' => pht('Change encoding for all files.'),
- ),
- array(
- 'name' => 'force',
- 'help' => pht(
- 'Re-encode files which are already stored in the target '.
- 'encoding.'),
- ),
- array(
- 'name' => 'names',
- 'wildcard' => true,
- ),
- ));
+ ->setArguments($arguments);
}
public function execute(PhutilArgumentParser $args) {
$iterator = $this->buildIterator($args);
- if (!$iterator) {
- throw new PhutilArgumentUsageException(
- pht(
- 'Either specify a list of files to encode, or use --all to '.
- 'encode all files.'));
- }
$force = (bool)$args->getArg('force');
diff --git a/src/applications/files/management/PhabricatorFilesManagementIntegrityWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementIntegrityWorkflow.php
--- a/src/applications/files/management/PhabricatorFilesManagementIntegrityWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementIntegrityWorkflow.php
@@ -4,52 +4,50 @@
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
+ $arguments = $this->newIteratorArguments();
+
+ $arguments[] = array(
+ 'name' => 'strip',
+ 'help' => pht(
+ 'DANGEROUS. Strip integrity hashes from files. This makes '.
+ 'files vulnerable to corruption or tampering.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'corrupt',
+ 'help' => pht(
+ 'Corrupt integrity hashes for given files. This is intended '.
+ 'for debugging.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'compute',
+ 'help' => pht(
+ 'Compute and update integrity hashes for files which do not '.
+ 'yet have them.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'overwrite',
+ 'help' => pht(
+ 'DANGEROUS. Recompute and update integrity hashes, overwriting '.
+ 'invalid hashes. This may mark corrupt or dangerous files as '.
+ 'valid.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'force',
+ 'short' => 'f',
+ 'help' => pht(
+ 'Execute dangerous operations without prompting for '.
+ 'confirmation.'),
+ );
+
+
$this
->setName('integrity')
->setSynopsis(pht('Verify or recalculate file integrity hashes.'))
- ->setArguments(
- array(
- array(
- 'name' => 'all',
- 'help' => pht('Affect all files.'),
- ),
- array(
- 'name' => 'strip',
- 'help' => pht(
- 'DANGEROUS. Strip integrity hashes from files. This makes '.
- 'files vulnerable to corruption or tampering.'),
- ),
- array(
- 'name' => 'corrupt',
- 'help' => pht(
- 'Corrupt integrity hashes for given files. This is intended '.
- 'for debugging.'),
- ),
- array(
- 'name' => 'compute',
- 'help' => pht(
- 'Compute and update integrity hashes for files which do not '.
- 'yet have them.'),
- ),
- array(
- 'name' => 'overwrite',
- 'help' => pht(
- 'DANGEROUS. Recompute and update integrity hashes, overwriting '.
- 'invalid hashes. This may mark corrupt or dangerous files as '.
- 'valid.'),
- ),
- array(
- 'name' => 'force',
- 'short' => 'f',
- 'help' => pht(
- 'Execute dangerous operations without prompting for '.
- 'confirmation.'),
- ),
- array(
- 'name' => 'names',
- 'wildcard' => true,
- ),
- ));
+ ->setArguments($arguments);
}
public function execute(PhutilArgumentParser $args) {
@@ -120,12 +118,6 @@
}
$iterator = $this->buildIterator($args);
- if (!$iterator) {
- throw new PhutilArgumentUsageException(
- pht(
- 'Either specify a list of files to affect, or use "--all" to '.
- 'affect all files.'));
- }
$failure_count = 0;
$total_count = 0;
diff --git a/src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
--- a/src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php
@@ -4,61 +4,54 @@
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
+ $arguments = $this->newIteratorArguments();
+
+ $arguments[] = array(
+ 'name' => 'engine',
+ 'param' => 'storage-engine',
+ 'help' => pht('Migrate to the named storage engine.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'dry-run',
+ 'help' => pht('Show what would be migrated.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'min-size',
+ 'param' => 'bytes',
+ 'help' => pht(
+ 'Do not migrate data for files which are smaller than a given '.
+ 'filesize.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'max-size',
+ 'param' => 'bytes',
+ 'help' => pht(
+ 'Do not migrate data for files which are larger than a given '.
+ 'filesize.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'copy',
+ 'help' => pht(
+ 'Copy file data instead of moving it: after migrating, do not '.
+ 'remove the old data even if it is no longer referenced.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'local-disk-source',
+ 'param' => 'path',
+ 'help' => pht(
+ 'When migrating from a local disk source, use the specified '.
+ 'path as the root directory.'),
+ );
+
$this
->setName('migrate')
->setSynopsis(pht('Migrate files between storage engines.'))
- ->setArguments(
- array(
- array(
- 'name' => 'engine',
- 'param' => 'storage_engine',
- 'help' => pht('Migrate to the named storage engine.'),
- ),
- array(
- 'name' => 'dry-run',
- 'help' => pht('Show what would be migrated.'),
- ),
- array(
- 'name' => 'min-size',
- 'param' => 'bytes',
- 'help' => pht(
- 'Do not migrate data for files which are smaller than a given '.
- 'filesize.'),
- ),
- array(
- 'name' => 'max-size',
- 'param' => 'bytes',
- 'help' => pht(
- 'Do not migrate data for files which are larger than a given '.
- 'filesize.'),
- ),
- array(
- 'name' => 'all',
- 'help' => pht('Migrate all files.'),
- ),
- array(
- 'name' => 'copy',
- 'help' => pht(
- 'Copy file data instead of moving it: after migrating, do not '.
- 'remove the old data even if it is no longer referenced.'),
- ),
- array(
- 'name' => 'names',
- 'wildcard' => true,
- ),
- array(
- 'name' => 'from-engine',
- 'param' => 'engine',
- 'help' => pht('Migrate files from the named storage engine.'),
- ),
- array(
- 'name' => 'local-disk-source',
- 'param' => 'path',
- 'help' => pht(
- 'When migrating from a local disk source, use the specified '.
- 'path as the root directory.'),
- ),
- ));
+ ->setArguments($arguments);
}
public function execute(PhutilArgumentParser $args) {
@@ -97,14 +90,6 @@
$target_engine = PhabricatorFile::buildEngine($target_key);
$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');
$min_size = (int)$args->getArg('min-size');
diff --git a/src/applications/files/management/PhabricatorFilesManagementRebuildWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementRebuildWorkflow.php
--- a/src/applications/files/management/PhabricatorFilesManagementRebuildWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementRebuildWorkflow.php
@@ -4,45 +4,33 @@
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
+ $arguments = $this->newIteratorArguments();
+
+ $arguments[] = array(
+ 'name' => 'dry-run',
+ 'help' => pht('Show what would be updated.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'rebuild-mime',
+ 'help' => pht('Rebuild MIME information.'),
+ );
+
+ $arguments[] = array(
+ 'name' => 'rebuild-dimensions',
+ 'help' => pht('Rebuild image dimension information.'),
+ );
+
$this
->setName('rebuild')
->setSynopsis(pht('Rebuild metadata of old files.'))
- ->setArguments(
- array(
- array(
- 'name' => 'all',
- 'help' => pht('Update all files.'),
- ),
- array(
- 'name' => 'dry-run',
- 'help' => pht('Show what would be updated.'),
- ),
- array(
- 'name' => 'rebuild-mime',
- 'help' => pht('Rebuild MIME information.'),
- ),
- array(
- 'name' => 'rebuild-dimensions',
- 'help' => pht('Rebuild image dimension information.'),
- ),
- array(
- 'name' => 'names',
- 'wildcard' => true,
- ),
- ));
+ ->setArguments($arguments);
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
$iterator = $this->buildIterator($args);
- if (!$iterator) {
- throw new PhutilArgumentUsageException(
- pht(
- 'Either specify a list of files to update, or use `%s` '.
- 'to update all files.',
- '--all'));
- }
$update = array(
'mime' => $args->getArg('rebuild-mime'),
diff --git a/src/applications/files/management/PhabricatorFilesManagementWorkflow.php b/src/applications/files/management/PhabricatorFilesManagementWorkflow.php
--- a/src/applications/files/management/PhabricatorFilesManagementWorkflow.php
+++ b/src/applications/files/management/PhabricatorFilesManagementWorkflow.php
@@ -3,11 +3,30 @@
abstract class PhabricatorFilesManagementWorkflow
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) {
$viewer = $this->getViewer();
- $names = $args->getArg('names');
$is_all = $args->getArg('all');
+
+ $names = $args->getArg('names');
$from_engine = $args->getArg('from-engine');
$any_constraint = ($from_engine || $names);
@@ -15,15 +34,16 @@
if (!$is_all && !$any_constraint) {
throw new PhutilArgumentUsageException(
pht(
- 'Use "--all" to migrate all files, or choose files to migrate '.
- 'with "--names" or "--from-engine".'));
+ 'Specify which files to operate on, or use "--all" to operate on '.
+ 'all files.'));
}
if ($is_all && $any_constraint) {
throw new PhutilArgumentUsageException(
pht(
- 'You can not migrate all files with "--all" and also migrate only '.
- 'a subset of files with "--from-engine" or "--names".'));
+ 'You can not operate on all files with "--all" and also operate '.
+ '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
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 7, 2:41 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7332930
Default Alt Text
D20614.diff (17 KB)
Attached To
Mode
D20614: Make "bin/files" parsing of working set arguments more consistent
Attached
Detach File
Event Timeline
Log In to Comment