From f23f41f9391258910a0443fd9ebfe278dde90767 Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Wed, 17 Aug 2011 16:14:28 +0000 Subject: add function to check if a binary file already exists --- MgaRepo/binrepo.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/MgaRepo/binrepo.py b/MgaRepo/binrepo.py index f76584b..650c366 100644 --- a/MgaRepo/binrepo.py +++ b/MgaRepo/binrepo.py @@ -156,17 +156,20 @@ def download_binaries(topdir): for name, sha1 in entries.iteritems(): download_binary(topdir, sha1, name) -def upload_binary(topdir, filename): - filepath = os.path.join(topdir, 'SOURCES', filename) - if not os.path.exists(filepath): - raise Error, "'%s' was not found" % spath - sha1sum = file_hash(filepath) +def binary_exists(sha1sum): dlurl = config.get("binrepo", "download_url", "http://binrepo.mageia.org/") dlurl = mirror.normalize_path(dlurl + "/" + sha1sum) h = httplib2.Http() resp, content = h.request(dlurl, 'HEAD') - if resp.status == 200: + return resp.status == 200: + +def upload_binary(topdir, filename): + filepath = os.path.join(topdir, 'SOURCES', filename) + if not os.path.exists(filepath): + raise Error, "'%s' was not found" % spath + sha1sum = file_hash(filepath) + if binary_exists(sha1sum): return host = config.get("binrepo", "upload_host") upload_bin_helper = get_helper("upload-bin") -- cgit v1.2.1