17 use Symfony\Component\Finder\Finder;
18 use Symfony\Component\Finder\SplFileInfo;
53 $typo3TempAssetsPath =
'/typo3temp/assets/';
55 if (is_dir($basePath)) {
56 $dirFinder =
new Finder();
57 $dirsInAssets = $dirFinder->directories()->in($basePath)->depth(0)->sortByName();
58 foreach ($dirsInAssets as $dirInAssets) {
60 $fileFinder =
new Finder();
61 $fileCount = $fileFinder->files()->in($dirInAssets->getPathname())->count();
62 $folderName = $dirInAssets->getFilename();
64 'directory' => $typo3TempAssetsPath . $folderName,
65 'numberOfFiles' => $fileCount,
67 if ($folderName ===
'_processed_') {
70 $stat[
'storageUid'] = 0;
86 $processedFileRepository = GeneralUtility::makeInstance(ProcessedFileRepository::class);
87 $storages = GeneralUtility::makeInstance(StorageRepository::class)->findAll();
88 foreach ($storages as $storage) {
89 if ($storage->isOnline()) {
90 $storageConfiguration = $storage->getConfiguration();
91 $storageBasePath = rtrim($storageConfiguration[
'basePath'],
'/');
92 $processedPath =
'/' . $storageBasePath . $storage->getProcessingFolder()->getIdentifier();
93 $numberOfFiles = $processedFileRepository->countByStorage($storage);
95 'directory' => $processedPath,
96 'numberOfFiles' => $numberOfFiles,
97 'storageUid' => $storage->getUid()
112 $repository = GeneralUtility::makeInstance(ProcessedFileRepository::class);
113 return $repository->removeAll($storageUid);
126 if (empty($folderName)
127 || !GeneralUtility::isAllowedAbsPath($basePath)
128 || strpos($folderName,
'/typo3temp/assets/') !== 0
130 throw new \RuntimeException(
131 'Path to folder ' . $folderName .
' not allowed.',
135 if (!is_dir($basePath)) {
136 throw new \RuntimeException(
137 'Folder path ' . $basePath .
' does not exist or is no directory.',
143 foreach ((
new Finder())->directories()->in($basePath)->depth(0) as $directory) {
145 GeneralUtility::rmdir($directory->getPathname(),
true);
149 foreach ((
new Finder())->files()->in($basePath)->depth(0) as $file) {
151 $path = $file->getPathname();