Add option to remove input file on completion

This commit is contained in:
Daniel Siepmann 2020-10-05 10:49:46 +02:00
parent 93c22ce548
commit 566b73ee04
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 11 additions and 0 deletions

View file

@ -15,6 +15,7 @@ use Symfony\Component\Console\SingleCommandApplication;
->addArgument('start', InputArgument::REQUIRED, 'The starting point of the video')
->addArgument('end', InputArgument::REQUIRED, 'The end point of the video')
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force generation, even if target already exists.')
->addOption('remove', 'r', InputOption::VALUE_NONE, 'Remove input file on success.')
->addOption('ad', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Start and end of ads, separate start and end via "/".', [])
->setCode(new Command())
->run();

View file

@ -87,6 +87,10 @@ class Command
$videoInfo->getTargetFilePath()
));
if ($input->getOption('remove')) {
$this->removeInputFile($videoInfo);
}
return 0;
}
@ -128,4 +132,10 @@ class Command
mkdir($target, 0775, true);
}
private function removeInputFile(VideoInfo $videoInfo)
{
$this->executeStep('Remove input file');
unlink($videoInfo->getOriginalFilename());
}
}