Skip to content

Commit e091429

Browse files
committed
feat: Allow to limit move/copy commands to used files (JB-1596)
1 parent 8634685 commit e091429

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

Classes/Command/AbstractCloudinaryCommand.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ protected function getFiles(ResourceStorage $storage, InputInterface $input): ar
9595
}
9696
}
9797

98+
if ((bool)$input->getOption('used-only')) {
99+
$query->join(
100+
'sys_file',
101+
'sys_file_reference',
102+
'sys_file_reference',
103+
$query->expr()->eq('sys_file_reference.uid_local', 'sys_file.uid'),
104+
);
105+
}
106+
98107
return $query->execute()->fetchAllAssociative();
99108
}
100109

Classes/Command/CloudinaryCopyCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ protected function configure(): void
5454
->addOption('filter-file-type', '', InputArgument::OPTIONAL, 'Add a possible filter for file type as defined by FAL (e.g 1,2,3,4,5)', '')
5555
->addOption('limit', '', InputArgument::OPTIONAL, 'Add a possible offset, limit to restrain the number of files. (eg. 0,100)', '')
5656
->addOption('exclude', '', InputArgument::OPTIONAL, 'Exclude pattern, can contain comma separated values e.g. --exclude="/apps/%,/_temp/%"', '')
57+
->addOption('used-only', '', InputArgument::OPTIONAL, 'Only copy used files (with sys_file_reference)', false)
5758
->addArgument('source', InputArgument::REQUIRED, 'Source storage identifier')
5859
->addArgument('target', InputArgument::REQUIRED, 'Target storage identifier')
5960
->setHelp('Usage: ./vendor/bin/typo3 cloudinary:copy 1 2');

Classes/Command/CloudinaryMoveCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ protected function configure(): void
4949
->addOption('filter-file-type', '', InputArgument::OPTIONAL, 'Add a possible filter for file type as defined by FAL (e.g 1,2,3,4,5)', '')
5050
->addOption('limit', '', InputArgument::OPTIONAL, 'Add a possible offset, limit to restrain the number of files. (eg. 0,100)', '')
5151
->addOption('exclude', '', InputArgument::OPTIONAL, 'Exclude pattern, can contain comma separated values e.g. --exclude="/apps/%,/_temp/%"', '')
52+
->addOption('used-only', '', InputArgument::OPTIONAL, 'Only move used files (with sys_file_reference)', false)
5253
->addArgument('source', InputArgument::REQUIRED, 'Source storage identifier')
5354
->addArgument('target', InputArgument::REQUIRED, 'Target storage identifier')
5455
->setHelp('Usage: ./vendor/bin/typo3 cloudinary:move 1 2');

0 commit comments

Comments
 (0)