andersundsehr / aus_driver_amazon_s3

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

Exception when moving a folder: Undefined array key "Contents" #148

Closed cweiske closed 2 weeks ago

cweiske commented 3 months ago

When moving an existing folder via drag-and-drop into another folder, a 500 HTTP error is returned. The folder is moved, though.

Stack trace:

ErrorException: Warning: Undefined array key "Contents"
#47 /vendor/andersundsehr/aus-driver-amazon-s3/Classes/Driver/AmazonS3Driver.php(1549): AUS\AusDriverAmazonS3\Driver\AmazonS3Driver::getSubObjects
#46 /vendor/andersundsehr/aus-driver-amazon-s3/Classes/Driver/AmazonS3Driver.php(694): AUS\AusDriverAmazonS3\Driver\AmazonS3Driver::moveFolderWithinStorage
#45 /vendor/typo3/cms-core/Classes/Resource/ResourceStorage.php(2221): TYPO3\CMS\Core\Resource\ResourceStorage::moveFolder
#44 /vendor/typo3/cms-core/Classes/Resource/Folder.php(389): TYPO3\CMS\Core\Resource\Folder::moveTo
#43 /vendor/typo3/cms-core/Classes/Utility/File/ExtendedFileUtility.php(754): TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::func_move
#42 /vendor/typo3/cms-core/Classes/Utility/File/ExtendedFileUtility.php(257): TYPO3\CMS\Core\Utility\File\ExtendedFileUtility::processData
#41 /vendor/typo3/cms-backend/Classes/Controller/File/FileController.php(248): TYPO3\CMS\Backend\Controller\File\FileController::main

Relevant code:

    protected function getSubObjects($identifier, $recursive = true, $filter = self::FILTER_ALL)
    {
        $result = $this->getListObjects($identifier);
        if (!is_array($result['Contents'])) {
            return [];
        }

This is with TYPO3 12.4.13 and andersundsehr/aus-driver-amazon-s3 1.12.1. This is old, but the same code is still in current master.

cweiske commented 2 weeks ago

This is probably a MinIO specific problem that might not affect S3, because when renaming a folder in MinIO, all children are renamed automatically.

moveFolderWithinStorage and renameSubFolder are similare but have one difference:

A solution would be to make both behave the same: First rename children, then rename the folder.

cweiske commented 2 weeks ago

This happens when an empty folder is moved via drag and drop.

The comment above is not correct; when the folder is empty, MinIO simply does not return the "Contents" key in the response.