main: create intermediate directories for cachedir

Fixes: https://pagure.io/fedora-rust/rust2rpm/issue/50
Merges: https://pagure.io/fedora-rust/rust2rpm/pull-request/56
This commit is contained in:
Luca Bruno 2018-08-15 18:47:05 +02:00 committed by Igor Gnatenko
parent 0e3c6e777c
commit 2c1e19f4eb
No known key found for this signature in database
GPG key ID: 695714BD1BBC5F4C

View file

@ -101,8 +101,7 @@ def download(crate, version):
versions = req.json()["versions"] versions = req.json()["versions"]
version = next(version["num"] for version in versions if not version["yanked"]) version = next(version["num"] for version in versions if not version["yanked"])
if not os.path.isdir(CACHEDIR): os.makedirs(CACHEDIR, exist_ok=True)
os.mkdir(CACHEDIR)
cratef_base = "{}-{}.crate".format(crate, version) cratef_base = "{}-{}.crate".format(crate, version)
cratef = os.path.join(CACHEDIR, cratef_base) cratef = os.path.join(CACHEDIR, cratef_base)
if not os.path.isfile(cratef): if not os.path.isfile(cratef):