1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-23 12:09:12 +01:00
phorge-phorge/src/applications/files/management/PhabricatorFilesManagementPurgeWorkflow.php
Joshua Spence daadf95537 Fix visibility of PhutilArgumentWorkflow::didConstruct methods
Summary: Ref T6822.

Test Plan: `grep`. This method is only called from within `PhutilArgumentWorkflow::__construct`.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Maniphest Tasks: T6822

Differential Revision: https://secure.phabricator.com/D11415
2015-01-16 07:42:07 +11:00

69 lines
1.6 KiB
PHP

<?php
final class PhabricatorFilesManagementPurgeWorkflow
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
$this
->setName('purge')
->setSynopsis('Delete files with missing data.')
->setArguments(
array(
array(
'name' => 'all',
'help' => 'Update all files.',
),
array(
'name' => 'dry-run',
'help' => 'Show what would be updated.',
),
array(
'name' => 'names',
'wildcard' => true,
),
));
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
$iterator = $this->buildIterator($args);
if (!$iterator) {
throw new PhutilArgumentUsageException(
'Either specify a list of files to purge, or use `--all` '.
'to purge all files.');
}
$is_dry_run = $args->getArg('dry-run');
foreach ($iterator as $file) {
$fid = 'F'.$file->getID();
try {
$file->loadFileData();
$okay = true;
} catch (Exception $ex) {
$okay = false;
}
if ($okay) {
$console->writeOut(
"%s: File data is OK, not purging.\n",
$fid);
} else {
if ($is_dry_run) {
$console->writeOut(
"%s: Would purge (dry run).\n",
$fid);
} else {
$console->writeOut(
"%s: Purging.\n",
$fid);
$file->delete();
}
}
}
return 0;
}
}