Esempio n. 1
0
def fill_filedetail():    
    for r in Repository.select():
        d = r.directory
        try:
            d = Directory.byName("%s/repodata" % (d.name))
        except:
            print "warning: Repository at Directory %s missing repodata subdir" % d.name
            continue
        for fd in d.fileDetails:
            if fd.filename == 'repomd.xml':
                try:
                    fname = "/%s/repomd.xml" % (d.name)
                    f = open(fname, 'rb')
                    s = f.read()
                    f.close()
                    h  = hashlib.sha256(s).hexdigest()
                    print "sha256=%s" % h
                    fd.sha256 =h
                    fd.sha512 = hashlib.sha512(s).hexdigest()
                    fd.sync()
                    del s
                except:
                    print "warning: couldn't update sha checksums for %s" % fname
                # only add to the most recent one
                break
Esempio n. 2
0
def file_details_cache():
    # cache{directoryname}{filename}[{details}]
    cache = {}
    # materialize this select to avoid making hundreds of thousands of queries
    for d in list(Directory.select()):
        if len(d.fileDetails) > 0:
            cache[d.name] = {}
            for fd in list(d.fileDetails):
                details = dict(timestamp=fd.timestamp, sha1=fd.sha1, md5=fd.md5, sha256=fd.sha256, sha512=fd.sha512, size=fd.size)
                append_value_to_cache(cache[d.name], fd.filename, details)
    return cache