summaryrefslogtreecommitdiffstats
path: root/layman/db.py
diff options
context:
space:
mode:
authordol-sen <brian.dolbec@gmail.com>2011-07-28 14:29:12 -0700
committerdol-sen <brian.dolbec@gmail.com>2011-07-28 14:29:12 -0700
commitb08a5e4b34e0258e84714bcef16c1d5d09c71b39 (patch)
tree371e85ec09b449f5f42c9de1d8d14fac1bd2ed04 /layman/db.py
parent0fde69e7ef993c3e5cca925cef35c8c895cfd834 (diff)
downloadlayman-b08a5e4b34e0258e84714bcef16c1d5d09c71b39.tar.gz
layman-b08a5e4b34e0258e84714bcef16c1d5d09c71b39.tar.bz2
layman-b08a5e4b34e0258e84714bcef16c1d5d09c71b39.zip
fix setting the timestamp from the remote server, bug # 376601.
Diffstat (limited to 'layman/db.py')
-rw-r--r--layman/db.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/layman/db.py b/layman/db.py
index bb6fd81..64b54ce 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -319,7 +319,12 @@ class RemoteDB(DbBase):
try:
connection = opener.open(request)
- timestamp = connection.headers['last-modified']
+ if 'last-modified' in connection.headers.keys():
+ timestamp = connection.headers['last-modified']
+ elif 'date' in connection.headers.keys():
+ timestamp = connection.headers['date']
+ else:
+ timestamp = None
except urllib2.HTTPError as e:
if e.getcode() == 304:
self.output.info('Remote list already up to date: %s'
@@ -330,15 +335,16 @@ class RemoteDB(DbBase):
% str(e))
continue
except IOError as error:
- self.output.warn('Failed to update the overlay list from: '
- + url + '\nError was:\n' + str(error))
+ self.output.warn('RemoteDB.cache(); Failed to update the overlay list from: '
+ + url + '\nIOError was:\n' + str(error))
else:
if url.startswith('file://'):
quieter = 1
else:
quieter = 0
self.output.info('Fetching new list... %s' % url, 4 + quieter)
- self.output.info('Last-modified: %s' % timestamp, 4 + quieter)
+ if timestamp is not None:
+ self.output.info('Last-modified: %s' % timestamp, 4 + quieter)
# Fetch the remote list
olist = connection.read()
@@ -368,9 +374,10 @@ class RemoteDB(DbBase):
out_file.write(olist)
out_file.close()
- out_file = open(tpath, 'w')
- out_file.write(timestamp)
- out_file.close()
+ if timestamp is not None:
+ out_file = open(tpath, 'w')
+ out_file.write(str(timestamp))
+ out_file.close()
has_updates = True