Bug #101725
closedPlease execute FileDeletionAspect regardless if file is missing or not
100%
Description
Hello,
I have a command to delete a lot of related files of a customers table.
The command should remove files older than 3 years.
In some cases the file is already deleted, but the sys_file_reference, sys_file_metadata and maybe the processed data is still available in DB.
While deleting such a record with missing file over official API I get following error message:
You are not allowed to delete the file "pictures/2019/hockey.jpg"
This message is not correct and it has nothing to do with insufficient permissions.
This is my TYPO3 API call:
$fileReference = $resourceFactory->getFileReferenceObject( $sysFileReferenceRecord['uid'], $sysFileReferenceRecord ); $fileReference->getOriginalFile()->getStorage()->deleteFile($fileReference->getOriginalFile());
This is the problem IMO in TYPO3 core. ResourceStorage::checkFileActionPermission
// Check 5: Check the capabilities of the storage (and the driver) if ($isWriteCheck && ($isMissing || !$this->isWritable())) { return false; }
Just a missing file, is not a indication of missing permissions. IMO, we should split these two conditions into separate ones with different return values or throw an exception, if file is missing.