Fix S3 directory location infinite loop

Fixes #1722