Fixed bug with filename clashes (can happen if a file gets deleted from the db)