Merge branch 'fix-blob-race-condition'

This commit is contained in:
Jack Robison 2018-06-14 17:54:36 -04:00
commit 408e1bff72
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 4 additions and 7 deletions

View file

@ -14,7 +14,7 @@ at anytime.
### Fixed ### Fixed
* fixed token validation error when the dht node has just been started (https://github.com/lbryio/lbry/issues/1248) * fixed token validation error when the dht node has just been started (https://github.com/lbryio/lbry/issues/1248)
* * fixed a race condition when inserting a blob into the database (https://github.com/lbryio/lbry/issues/1129)
### Deprecated ### Deprecated
* *

View file

@ -226,12 +226,9 @@ class SQLiteStorage(object):
@defer.inlineCallbacks @defer.inlineCallbacks
def add_known_blob(self, blob_hash, length): def add_known_blob(self, blob_hash, length):
status = yield self.get_blob_status(blob_hash) yield self.db.runOperation(
if status is None: "insert or ignore into blob values (?, ?, ?, ?, ?, ?, ?)", (blob_hash, length, 0, 0, "pending", 0, 0)
status = "pending" )
yield self.db.runOperation("insert into blob values (?, ?, ?, ?, ?, ?, ?)",
(blob_hash, length, 0, 0, status, 0, 0))
defer.returnValue(status)
def should_announce(self, blob_hash): def should_announce(self, blob_hash):
return self.run_and_return_one_or_none( return self.run_and_return_one_or_none(