-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from alchemy-fr/PS-578_dictionary-save-client-…
…side PS-578_dictionary-save-client-side
- Loading branch information
Showing
5 changed files
with
91 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
use Monolog\Handler\NullHandler; | ||
use Monolog\Handler\StreamHandler; | ||
use Monolog\Logger; | ||
use PHPExiftool\ClassUtils\tagGroupBuilder; | ||
use PHPExiftool\Exiftool; | ||
use PHPExiftool\InformationDumper; | ||
use PHPExiftool\PHPExiftool; | ||
|
@@ -29,7 +30,7 @@ | |
* @author Romain Neutron - [email protected] | ||
* @license http://opensource.org/licenses/MIT MIT | ||
*/ | ||
class ClassesBuilder extends Command | ||
class ClassesBuilderCommand extends Command | ||
{ | ||
protected InputInterface $input; | ||
protected OutputInterface $output; | ||
|
@@ -80,14 +81,27 @@ protected function execute(InputInterface $input, OutputInterface $output): int | |
} | ||
|
||
|
||
$dumper = new InformationDumper(new Exiftool($logger), $input->getOption('path')); | ||
$dumper->setLogger($logger); | ||
$path = realpath($input->getOption('path')); | ||
$subPath = $path . '/' . PHPExiftool::SUBDIR; // security : do NOT rm passed cli option | ||
@mkdir($subPath, 0755, true); | ||
$logger->info(sprintf('Erasing previous files "%s/*" ', $subPath)); | ||
try { | ||
$cmd = 'rm -Rf ' . $subPath . '/* 2> /dev/null'; | ||
$output = []; | ||
@exec($cmd, $output); | ||
} | ||
catch (\Exception $e) { | ||
// no-op | ||
} | ||
$logger->info('Generating classes... '); | ||
|
||
$dumper->dumpClasses($options, $input->getOption('lng')); | ||
$PHPExiftool = new PHPExiftool($path, $logger); | ||
$nClasses = $PHPExiftool->generateClasses($options, $input->getOption('lng')); | ||
|
||
$this->output->writeln( | ||
sprintf( | ||
'Generated in %d seconds (%d Mb)', | ||
'Generated %d classes in %d seconds (%d Mb)', | ||
$nClasses, | ||
(microtime(true) - $start), | ||
memory_get_peak_usage() >> 20 | ||
) | ||
|