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
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue