forked from LBRYCommunity/lbry-sdk
add migrator for previous bugs
This commit is contained in:
parent
e8683a24bd
commit
6c142b4477
1 changed files with 20 additions and 0 deletions
20
lbrynet/extras/daemon/migrator/migrate9to10.py
Normal file
20
lbrynet/extras/daemon/migrator/migrate9to10.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import sqlite3
|
||||
import os
|
||||
|
||||
|
||||
def do_migration(conf):
|
||||
db_path = os.path.join(conf.data_dir, "lbrynet.sqlite")
|
||||
connection = sqlite3.connect(db_path)
|
||||
cursor = connection.cursor()
|
||||
|
||||
query = "select stream_hash, sd_hash from main.stream"
|
||||
for stream_hash, sd_hash in cursor.execute(query):
|
||||
head_blob_hash = cursor.execute(
|
||||
"select blob_hash from stream_blob where position = 0 and stream_hash = ?",
|
||||
(stream_hash,)
|
||||
).fetchone()
|
||||
if not head_blob_hash:
|
||||
continue
|
||||
cursor.execute("update blob set should_announce=1 where blob_hash in (?, ?)", (sd_hash, head_blob_hash[0],))
|
||||
connection.commit()
|
||||
connection.close()
|
Loading…
Reference in a new issue