Logo Search packages:      
Sourcecode: harvestman version File versions  Download package

def HarvestMan::datamgr::harvestManDataManager::is_url_cache_uptodate (   self,

Check with project cache and find out if the
content needs update 

Definition at line 133 of file datamgr.py.

00133                                                                        :
        """ Check with project cache and find out if the
        content needs update """

        # Sep 16 2003, fixed a bug in this, we need to check
        # the file existence also.

        # If page caching is not enabled, return False
        # straightaway!
        if not self._cfg.pagecache:
            return (False, False)

        # Return True if cache is uptodate(no update needed)
        # and Fals if cache is out-of-date(update needed)
        # NOTE: We are using an comparison of the md5 checksum of
        # the file's data with the md5 checksum of the cache file.
        if contentlen==0:
            return (False, False)

        # Look up the dictionary containing the url cache info
        import md5


        # Assume that cache is not uptodate apriori

        # Reference to dictionary in the cache list
        cachekey = {}
        d = self._projectcache
        if d.has_key(intern(url)):
            cachekey = d[intern(url)]

            fileloc = cachekey[intern('location')]
            if os.path.exists(fileloc) and os.path.abspath(fileloc) == os.path.abspath(filename):
            if cachekey.has_key(intern('checksum')):
                # This value is stored hex encrypted in the cache file
                # (and hence the dictionary). In order to compare, we need
                # to decrypt it, (or we need to compare it with the encrypted
                # copy of the file digest, as we are doing now).
                cachemd5 = bin_decrypt(cachekey[intern('checksum')])
                if binascii.hexlify(cachemd5) == binascii.hexlify(digest1) and fileverified:

        # If cache is not updated, update all cache keys
        if not uptodate:
            cachekey[intern('checksum')] = bin_crypt(digest1)
            cachekey[intern('location')] = filename
            cachekey[intern('content-length')] = contentlen
            cachekey[intern('updated')] = True
            if self._cfg.datacache:
                cachekey['data'] = urldata

            self._projectcache[intern(url)] = cachekey

        # If both checksums are equal, return True
        # else return False.
        # Modification (Oct 1 2004) - Combine
        # with fileverified boolean.
        return (uptodate, fileverified)

Generated by  Doxygen 1.6.0   Back to index