Fix downloading invalid files

If users request an invalid file an unhandled exception occurs since we're
trying to track download statistics.
Let's abort execution if the requested files couldn't be loaded.
Merge pull request #1629 from mlocati/fix-download-invalid-files

Fix downloading invalid files