Changeset 3511c0b in osmose-backend


Ignore:
Timestamp:
Jan 13, 2013 12:47:14 PM (7 years ago)
Author:
Jocelyn Jaubert <jocelyn.jaubert@…>
Branches:
master
Children:
87eca0a
Parents:
8e089e6
git-author:
Frédéric Rodrigo <frodrigo@…> (12/01/2013 11:45:59)
git-committer:
Jocelyn Jaubert <jocelyn.jaubert@…> (13/01/2013 12:47:14)
Message:

Support http error and return cached data, change file name cache layout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/downloader.py

    r7c79ba3 r3511c0b  
    3434        os.makedirs(config.dir_cache) 
    3535 
    36     url_file_name = os.path.basename(urlparse.urlparse(url).path) 
    37     file_name = "%s-%s" % (url_file_name, hashlib.sha1(url).hexdigest()) 
     36    file_name = hashlib.sha1(url).hexdigest() 
    3837    cache = os.path.join(config.dir_cache, file_name) 
    3938    tmp_file = cache + ".tmp" 
     
    5857            # not newer 
    5958            os.utime(cache, (cur_time,cur_time)) 
    60             return cache 
    61         else: 
    62             raise exc 
     59        return cache 
    6360 
    6461    # write the file 
     
    7370        outfile.close() 
    7471 
     72    outfile = open(cache+".url", "w") 
     73    outfile.write(url) 
     74    outfile.close() 
    7575    os.rename(tmp_file, cache) 
    7676 
Note: See TracChangeset for help on using the changeset viewer.