ctx.download_resource creates directories needlessly


When target_path is None, the download_resource function is expected to download the resource into a temporary file.

What it actually ends up doing, is downloading the resource into a temporary file located in a brand new temporary directory:


The results:

  • Way too many directories created for no reason

  • In order to do proper cleanup, the caller needs to know that they should delete the temporary file's directory, and not just the temporary file itself


Isaac Shabtay
December 5, 2017, 9:28 PM

(Leaving this issue here rather than deleting it, so others who may wonder about this will find the explanation)

When target_path is None, we download the resource by preserving its basename. That requires us to download into a new directory each time.

Overall the best approach is to always provide target_path, and then delete the resource after usage.

Won't Fix


Isaac Shabtay


Isaac Shabtay