Closed jurajsulek closed 1 year ago
Please provide steps how to reproduce the problem.
i don't have the exact code anymore but this should do the same:
$storageRepository = GeneralUtility::makeInstance(StorageRepository::class); $storage = $storageRepository->getStorageObject(1); $folder = $storage->getFolder('data/aaaa/'); $files = $storage->getFilesInFolder($folder); $storage->renameFile('data/aaaa/aa.txt', 'data/aaaa/bb.txt'); // the file was in the folder $files = $storage->getFilesInFolder($folder);
now in $files is still the old name of the file because when $files = $storage->getFilesInFolder($folder); as called first it cached the result in a php variable and didn't clear the cache when renameFile was used
This is cache related. When getListObjects() is called, the function getCachedResponse creates a new cache entry. But you don't delete this cache e.g. after file renaming in the same folder. So if you call it then again you will receive the cache entry and not the actual status.
So in this case: try { storage->getFilesInFolder($folder); storage->renameFile($oldName, $newName); storage->getFilesInFolder($folder); }
you get an error that the file folder/oldname does not exist. Because when the getListObjects() is called, it returns the cached result from first storage->getFilesInFolder($folder); before the renaming