3 final class PhabricatorFilesManagementCycleWorkflow
4 extends PhabricatorFilesManagementWorkflow
{
6 protected function didConstruct() {
7 $arguments = $this->newIteratorArguments();
11 'help' => pht('Select a specific storage key to cycle to.'),
17 pht('Cycle master key for encrypted files.'))
18 ->setArguments($arguments);
21 public function execute(PhutilArgumentParser
$args) {
22 $iterator = $this->buildIterator($args);
24 $format_map = PhabricatorFileStorageFormat
::getAllFormats();
25 $engines = PhabricatorFileStorageEngine
::loadAllEngines();
27 $key_name = $args->getArg('key');
30 foreach ($iterator as $file) {
31 $monogram = $file->getMonogram();
33 $engine_key = $file->getStorageEngine();
34 $engine = idx($engines, $engine_key);
40 '%s: Uses unknown storage engine "%s".',
47 if ($engine->isChunkEngine()) {
51 '%s: Stored as chunks, declining to cycle directly.',
56 $format_key = $file->getStorageFormat();
57 if (empty($format_map[$format_key])) {
61 '%s: Uses unknown storage format "%s".',
68 $format = clone $format_map[$format_key];
69 $format->setFile($file);
71 if (!$format->canCycleMasterKey()) {
75 '%s: Storage format ("%s") does not support key cycling.',
77 $format->getStorageFormatName()));
84 '%s: Cycling master key.',
89 $format->selectMasterKey($key_name);
92 $file->cycleMasterStorageKey($format);
97 } catch (Exception
$ex) {
100 pht('Failed! %s', (string)$ex));
106 $monograms = mpull($failed, 'getMonogram');
110 pht('Failures: %s.', implode(', ', $monograms)));