From 1ea49e3b97d2419d313c00f7ba8c73458b370c72 Mon Sep 17 00:00:00 2001 From: Yves Marcoz Date: Tue, 23 Nov 2010 22:58:43 -0800 Subject: [PATCH] Fixed updating issues --- src/qml/common/ConfirmationMessage.qml | 6 ++++-- src/rss_sqlite.py | 35 ++++++++++++++++++++------------ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/qml/common/ConfirmationMessage.qml b/src/qml/common/ConfirmationMessage.qml index 1a5f1f8..eda34d0 100644 --- a/src/qml/common/ConfirmationMessage.qml +++ b/src/qml/common/ConfirmationMessage.qml @@ -31,7 +31,8 @@ Rectangle { Button { id: ok text: qsTr("OK") - anchors.left: parent.left; anchors.margins: 5; y: 3; width: 80; height: 60 + width: parent.width/2 - 10; + anchors.left: parent.left; anchors.margins: 5; y: 3; height: 60 anchors.top: question.bottom //anchors.bottom: parent.bottom onClicked: confirmationMessage.okClicked() @@ -40,7 +41,8 @@ Rectangle { Button { id: cancel text: qsTr("Cancel") - anchors.right: parent.right; anchors.margins: 5; y: 3; width: 80; height: 60 + width: parent.width/2 - 10; + anchors.right: parent.right; anchors.margins: 5; y: 3; height: 60 anchors.top: question.bottom //anchors.bottom: parent.bottom anchors.left: ok.right diff --git a/src/rss_sqlite.py b/src/rss_sqlite.py index 0b1aae1..e0f7e42 100644 --- a/src/rss_sqlite.py +++ b/src/rss_sqlite.py @@ -149,16 +149,17 @@ class Feed: import traceback traceback.print_exc() print "Error downloading image %s" % img - tmpEntry["contentLink"] = configdir+self.key+".d/"+id+".html" - file = open(tmpEntry["contentLink"], "w") - file.write(soup.prettify()) - file.close() - if id in ids: - self.db.execute("UPDATE feed SET updated=? WHERE id=?;", (currentTime, id) ) - self.db.commit() - else: - values = (id, tmpEntry["title"], tmpEntry["contentLink"], tmpEntry["date"], currentTime, tmpEntry["link"], 0) - self.db.execute("INSERT INTO feed (id, title, contentLink, date, updated, link, read) VALUES (?, ?, ?, ?, ?, ?, ?);", values) + tmpEntry["contentLink"] = configdir+self.key+".d/"+id+".html" + file = open(tmpEntry["contentLink"], "w") + file.write(soup.prettify()) + file.close() + if id in ids: + self.db.execute("UPDATE feed SET updated=? WHERE id=?;", (currentTime, id) ) + self.db.commit() + else: + values = (id, tmpEntry["title"], tmpEntry["contentLink"], tmpEntry["date"], currentTime, tmpEntry["link"], 0) + self.db.execute("INSERT INTO feed (id, title, contentLink, date, updated, link, read) VALUES (?, ?, ?, ?, ?, ?, ?);", values) + self.db.commit() # else: # try: # self.db.execute("UPDATE feed SET updated=? WHERE id=?;", (currentTime, id) ) @@ -251,7 +252,11 @@ class Feed: if(entry["id"] != None): return getId(str(entry["id"])) else: - return getId(str(entry["date"]) + str(entry["title"])) + try: + return getId(str(entry["date"]) + str(entry["title"])) + except: + #print entry["title"] + return getId(str(entry["date"])) def getIds(self, onlyUnread=False): if onlyUnread: @@ -492,10 +497,14 @@ class Listing: except: modified = None (updateTime, etag, modified) = feed.updateFeed(self.configdir, url, etag, modified, expiryTime, proxy, imageCache) + if modified==None: + modified="None" + else: + modified=str(tuple(modified)) if updateTime > 0: - db.execute("UPDATE feeds SET updateTime=?, etag=?, modified=? WHERE id=?;", (updateTime, etag, str(tuple(modified)), key) ) + db.execute("UPDATE feeds SET updateTime=?, etag=?, modified=? WHERE id=?;", (updateTime, etag, modified, key) ) else: - db.execute("UPDATE feeds SET etag=?, modified=? WHERE id=?;", (etag, str(tuple(modified)), key) ) + db.execute("UPDATE feeds SET etag=?, modified=? WHERE id=?;", (etag, modified, key) ) db.commit() self.updateUnread(key, db=db) -- 1.7.9.5