andersundsehr / aus_driver_amazon_s3

Provides a TYPO3 FAL driver for the Amazon Web Service S3
GNU Lesser General Public License v3.0
21 stars 40 forks source link

Error in storage->getFilesInFolder after file rename #123

Closed jurajsulek closed 1 year ago

jurajsulek commented 1 year ago

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

cweiske commented 1 year ago

Please provide steps how to reproduce the problem.

jurajsulek commented 1 year ago

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