diff options
author | Nicolas Vigier <boklm@mageia.org> | 2011-08-17 16:14:28 +0000 |
---|---|---|
committer | Nicolas Vigier <boklm@mageia.org> | 2011-08-17 16:14:28 +0000 |
commit | f23f41f9391258910a0443fd9ebfe278dde90767 (patch) | |
tree | a1cb860209e5a947af7e70ec3cbe7f82200bef4a | |
parent | 457131580c3e3f5387d72c4811d81e8ddb3c45f4 (diff) | |
download | mgarepo-f23f41f9391258910a0443fd9ebfe278dde90767.tar mgarepo-f23f41f9391258910a0443fd9ebfe278dde90767.tar.gz mgarepo-f23f41f9391258910a0443fd9ebfe278dde90767.tar.bz2 mgarepo-f23f41f9391258910a0443fd9ebfe278dde90767.tar.xz mgarepo-f23f41f9391258910a0443fd9ebfe278dde90767.zip |
add function to check if a binary file already exists
-rw-r--r-- | MgaRepo/binrepo.py | 15 |
1 files 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") |