Database.download: fix file names of downloaded files

Previously, all file names had the same name. This fixes issue #1164.