Fix broken download of directories

(cherry picked from commit 745c9a01243b8eefc72d89d1164d7d010b80983b)