BEGIN / END no longer necessary as there is no autocommit in new db module
This commit is contained in:
parent
a46d8fe7f3
commit
4fe4d0a7e7
6 changed files with 0 additions and 37 deletions
|
@ -144,9 +144,7 @@ class ChartCollector(object):
|
|||
|
||||
s = time.time()
|
||||
cur = self.db.getCursor()
|
||||
cur.execute("BEGIN")
|
||||
cur.cursor.executemany("INSERT INTO data (type_id, value, date_added) VALUES (?, ?, ?)", values)
|
||||
cur.execute("END")
|
||||
cur.close()
|
||||
self.log.debug("Global collectors inserted in %.3fs" % (time.time() - s))
|
||||
|
||||
|
@ -163,9 +161,7 @@ class ChartCollector(object):
|
|||
|
||||
s = time.time()
|
||||
cur = self.db.getCursor()
|
||||
cur.execute("BEGIN")
|
||||
cur.cursor.executemany("INSERT INTO data (type_id, site_id, value, date_added) VALUES (?, ?, ?, ?)", values)
|
||||
cur.execute("END")
|
||||
cur.close()
|
||||
self.log.debug("Site collectors inserted in %.3fs" % (time.time() - s))
|
||||
|
||||
|
|
|
@ -126,7 +126,6 @@ class ContentDbPlugin(object):
|
|||
if not site_id:
|
||||
return False
|
||||
cur = self.getCursor()
|
||||
cur.execute("BEGIN")
|
||||
res = cur.execute("SELECT * FROM content WHERE size_files_optional > 0 AND site_id = %s" % site_id)
|
||||
num = 0
|
||||
for row in res.fetchall():
|
||||
|
@ -135,7 +134,6 @@ class ContentDbPlugin(object):
|
|||
num += self.setContentFilesOptional(site, row["inner_path"], content, cur=cur)
|
||||
except Exception as err:
|
||||
self.log.error("Error loading %s into file_optional: %s" % (row["inner_path"], err))
|
||||
cur.execute("COMMIT")
|
||||
cur.close()
|
||||
|
||||
# Set my files to pinned
|
||||
|
@ -158,10 +156,6 @@ class ContentDbPlugin(object):
|
|||
def setContentFilesOptional(self, site, content_inner_path, content, cur=None):
|
||||
if not cur:
|
||||
cur = self
|
||||
try:
|
||||
cur.execute("BEGIN")
|
||||
except Exception as err:
|
||||
self.log.warning("Transaction begin error %s %s: %s" % (site, content_inner_path, Debug.formatException(err)))
|
||||
|
||||
num = 0
|
||||
site_id = self.site_ids[site.address]
|
||||
|
@ -193,11 +187,6 @@ class ContentDbPlugin(object):
|
|||
self.optional_files[site_id][file_inner_path[-8:]] = 1
|
||||
num += 1
|
||||
|
||||
if cur == self:
|
||||
try:
|
||||
cur.execute("END")
|
||||
except Exception as err:
|
||||
self.log.warning("Transaction end error %s %s: %s" % (site, content_inner_path, Debug.formatException(err)))
|
||||
return num
|
||||
|
||||
def setContent(self, site, inner_path, content, size=0):
|
||||
|
@ -269,10 +258,8 @@ class ContentDbPlugin(object):
|
|||
if peer_num != row["peer"]:
|
||||
updates[row["file_id"]] = peer_num
|
||||
|
||||
self.execute("BEGIN")
|
||||
for file_id, peer_num in updates.items():
|
||||
self.execute("UPDATE file_optional SET peer = ? WHERE file_id = ?", (peer_num, file_id))
|
||||
self.execute("END")
|
||||
|
||||
num_updated += len(updates)
|
||||
num_file += len(peer_nums)
|
||||
|
@ -415,8 +402,6 @@ class ContentDbPlugin(object):
|
|||
break
|
||||
|
||||
cur = self.getCursor()
|
||||
cur.execute("BEGIN")
|
||||
for file_id in deleted_file_ids:
|
||||
cur.execute("UPDATE file_optional SET is_downloaded = 0, is_pinned = 0, peer = peer - 1 WHERE ?", {"file_id": file_id})
|
||||
cur.execute("COMMIT")
|
||||
cur.close()
|
||||
|
|
|
@ -35,7 +35,6 @@ def processRequestLog():
|
|||
content_db = ContentDbPlugin.content_db
|
||||
cur = content_db.getCursor()
|
||||
num = 0
|
||||
cur.execute("BEGIN")
|
||||
for site_id in request_log:
|
||||
for inner_path, uploaded in request_log[site_id].items():
|
||||
content_db.execute(
|
||||
|
@ -43,7 +42,6 @@ def processRequestLog():
|
|||
{"site_id": site_id, "inner_path": inner_path}
|
||||
)
|
||||
num += 1
|
||||
cur.execute("END")
|
||||
request_log.clear()
|
||||
|
||||
|
||||
|
|
|
@ -77,7 +77,6 @@ class ContentDbPlugin(object):
|
|||
s = time.time()
|
||||
site_id = self.site_ids.get(site.address)
|
||||
cur = self.getCursor()
|
||||
cur.execute("BEGIN")
|
||||
try:
|
||||
cur.execute("DELETE FROM peer WHERE site_id = :site_id", {"site_id": site_id})
|
||||
cur.cursor.executemany(
|
||||
|
@ -86,8 +85,6 @@ class ContentDbPlugin(object):
|
|||
)
|
||||
except Exception as err:
|
||||
site.log.error("Save peer error: %s" % err)
|
||||
finally:
|
||||
cur.execute("END")
|
||||
site.log.debug("Peers saved in %.3fs" % (time.time() - s))
|
||||
|
||||
def initSite(self, site):
|
||||
|
|
|
@ -69,7 +69,6 @@ class FileRequestPlugin(object):
|
|||
i += 1
|
||||
|
||||
hashes_changed = 0
|
||||
db.execute("BEGIN")
|
||||
for onion, onion_hashes in onion_to_hash.items():
|
||||
hashes_changed += db.peerAnnounce(
|
||||
ip_type="onion",
|
||||
|
@ -78,7 +77,6 @@ class FileRequestPlugin(object):
|
|||
hashes=onion_hashes,
|
||||
onion_signed=all_onions_signed
|
||||
)
|
||||
db.execute("END")
|
||||
time_db_onion = time.time() - s
|
||||
|
||||
s = time.time()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue