Rev2089, Close the transaction on failed peer db save

This commit is contained in:
shortcutme 2017-05-24 10:40:10 +02:00
parent b73742839b
commit b0d574dfb0
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 11 additions and 7 deletions

View file

@ -73,11 +73,15 @@ class ContentDbPlugin(object):
site_id = self.site_ids.get(site.address) site_id = self.site_ids.get(site.address)
cur = self.getCursor() cur = self.getCursor()
cur.execute("BEGIN") cur.execute("BEGIN")
try:
self.execute("DELETE FROM peer WHERE site_id = :site_id", {"site_id": site_id}) self.execute("DELETE FROM peer WHERE site_id = :site_id", {"site_id": site_id})
self.cur.cursor.executemany( self.cur.cursor.executemany(
"INSERT INTO peer (site_id, address, port, hashfield, time_added) VALUES (?, ?, ?, ?, ?)", "INSERT INTO peer (site_id, address, port, hashfield, time_added) VALUES (?, ?, ?, ?, ?)",
self.iteratePeers(site) self.iteratePeers(site)
) )
except Exception, err:
site.log.error("Save peer error: %s" % err)
finally:
cur.execute("END") cur.execute("END")
site.log.debug("Peers saved in %.3fs" % (time.time() - s)) site.log.debug("Peers saved in %.3fs" % (time.time() - s))

View file

@ -10,7 +10,7 @@ class Config(object):
def __init__(self, argv): def __init__(self, argv):
self.version = "0.5.5" self.version = "0.5.5"
self.rev = 2088 self.rev = 2089
self.argv = argv self.argv = argv
self.action = None self.action = None
self.config_file = "zeronet.conf" self.config_file = "zeronet.conf"