r132 - /debtorrent/trunk/DebTorrent/HTTPCache.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Sat Jul 7 00:51:16 UTC 2007


Author: camrdale-guest
Date: Sat Jul  7 00:51:16 2007
New Revision: 132

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=132
Log:
Fix some cache problems with time zones.

Modified:
    debtorrent/trunk/DebTorrent/HTTPCache.py

Modified: debtorrent/trunk/DebTorrent/HTTPCache.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/HTTPCache.py?rev=132&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/HTTPCache.py (original)
+++ debtorrent/trunk/DebTorrent/HTTPCache.py Sat Jul  7 00:51:16 2007
@@ -28,7 +28,7 @@
 
 DEBUG = True
 
-time_format = '%a, %d %b %Y %H:%M:%S %Z'
+time_format = '%a, %d %b %Y %H:%M:%S'
 VERSION = product_name+'/'+version_short
 alas = 'your file may exist elsewhere in the universe\nbut alas, not here\n'
 
@@ -206,14 +206,14 @@
             
             # Set the modified time (on error use current time which should work)
             try:
-                mtime = timegm(strptime(r[2]['last-modified'], '%a, %d %b %Y %H:%M:%S %Z'))
+                mtime = timegm(strptime(r[2]['last-modified'], time_format + ' %Z'))
                 times = (mtime, mtime)
                 utime(file, times)
             except:
                 pass
 
         # Use the headers we want
-        mtime_string = strftime(time_format, gmtime(getmtime(file)))
+        mtime_string = strftime(time_format + ' GMT', gmtime(getmtime(file)))
         headers = {'Server': VERSION, 'last-modified': mtime_string}
         for k, v in r[2].items():
             if k in ('last-modified', 'content-type'):
@@ -270,7 +270,7 @@
         f = open(file, 'rb')
         data = f.read()
         f.close()
-        mtime_string = strftime(time_format, gmtime(getmtime(file)))
+        mtime_string = strftime(time_format+' GMT', gmtime(getmtime(file)))
         
         return (200, 'OK', {'Server': VERSION, 'Content-Type': 'text/plain', 'Last-Modified': mtime_string}, data)
 
@@ -327,8 +327,8 @@
             # Check the server's time against the cached copy
             server_mtime = getmtime(file)
         else:
-            server_mtime = timegm(strptime(server_mtime_string, time_format))
-
-        http_mtime = timegm(strptime(http_mtime_string, time_format))
+            server_mtime = timegm(strptime(server_mtime_string, time_format+' %Z'))
+
+        http_mtime = timegm(strptime(http_mtime_string, time_format+' %Z'))
 
         return http_mtime - server_mtime




More information about the Debtorrent-commits mailing list