I'm making use of the Hadoop FileStatus API to determine whether a folder is empty in order for the directory to be deleted.
To to determine if I have an empty directory on s3n, What I do is check for FileStatus[] length, if it equals to zero, then I request the Hadoop Filesystem to perform a delete via fs.delete(path, false). False here represents a non recursive delete request.
For FTP and HDFS, the files and then the empty directories containing these files are deleted as expected. But for S3n, the empty directories remain. I'm not sure why that is.
I have local unit/integration tests that use an in memory S3 filesystem, and here the delete works as expected. However when running the code against a real S3n filesystem, it fails (empty directories not deleted but files are).
Any suggestions or pointers would be much appreciated. thank you.