save cache into $XDG_CACHE_HOME/rust2rpm
Signed-off-by: Igor Gnatenko <ignatenkobrain@fedoraproject.org>
This commit is contained in:
parent
281f6f3c89
commit
619f221cc0
1 changed files with 5 additions and 1 deletions
|
@ -10,6 +10,8 @@ import requests
|
|||
|
||||
import cargodeps
|
||||
|
||||
XDG_CACHE_HOME = os.getenv("XDG_CACHE_HOME", os.path.expanduser("~/.cache"))
|
||||
CACHEDIR = os.path.join(XDG_CACHE_HOME, "rust2rpm")
|
||||
API_URL = "https://crates.io/api/v1/"
|
||||
TEMPLATE = """# Generated by rust2rpm
|
||||
%bcond_without check
|
||||
|
@ -111,7 +113,9 @@ if __name__ == "__main__":
|
|||
req.raise_for_status()
|
||||
args.version = req.json()["versions"][0]["num"]
|
||||
|
||||
cratef = "{}-{}.crate".format(args.crate, args.version)
|
||||
if not os.path.isdir(CACHEDIR):
|
||||
os.mkdir(CACHEDIR)
|
||||
cratef = os.path.join(CACHEDIR, "{}-{}.crate".format(args.crate, args.version))
|
||||
if not os.path.isfile(cratef):
|
||||
url = requests.compat.urljoin(API_URL, "crates/{}/{}/download#".format(args.crate, args.version))
|
||||
req = requests.get(url, stream=True)
|
||||
|
|
Loading…
Reference in a new issue