recovered an old stash

This commit is contained in:
Lex Berezhny 2018-06-12 11:54:01 -04:00 committed by Jack Robison
parent 56175df121
commit fb2fb5c38c
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
5 changed files with 23 additions and 19 deletions

View file

@ -1 +1 @@
import paths
from . import paths

View file

@ -1,4 +1,4 @@
from blob_file import BlobFile
from creator import BlobFileCreator
from writer import HashBlobWriter
from reader import HashBlobReader
from .blob_file import BlobFile
from .creator import BlobFileCreator
from .writer import HashBlobWriter
from .reader import HashBlobReader

View file

@ -339,7 +339,7 @@ class Config(object):
self._data[TYPE_DEFAULT].update(self._fixed_defaults)
self._data[TYPE_DEFAULT].update(
{k: v[1] for (k, v) in self._adjustable_defaults.iteritems()})
{k: v[1] for (k, v) in self._adjustable_defaults.items()})
if persisted_settings is None:
persisted_settings = {}
@ -646,7 +646,7 @@ settings = None
def get_default_env():
env_defaults = {}
for k, v in ADJUSTABLE_SETTINGS.iteritems():
for k, v in ADJUSTABLE_SETTINGS.items():
if len(v) == 3:
env_defaults[k] = (v[0], None, v[2])
elif len(v) == 4:

View file

@ -62,9 +62,9 @@ def safe_stop_looping_call(looping_call):
def generate_id(num=None):
h = get_lbry_hash_obj()
if num is not None:
h.update(str(num))
h.update(str(num).encode())
else:
h.update(str(random.getrandbits(512)))
h.update(str(random.getrandbits(512)).encode())
return h.digest()

View file

@ -11,6 +11,7 @@ from lbryschema.decode import smart_decode
from lbrynet import conf
from lbrynet.cryptstream.CryptBlob import CryptBlobInfo
from lbrynet.dht.constants import dataExpireTimeout
from lbrynet.wallet.database import SQLiteWalletStorage
from torba.constants import COIN
log = logging.getLogger(__name__)
@ -94,7 +95,8 @@ class SqliteConnection(adbapi.ConnectionPool):
cls.reactor = reactor
class SQLiteStorage(object):
class SQLiteStorage(SQLiteWalletStorage):
CREATE_TABLES_QUERY = """
pragma foreign_keys=on;
pragma journal_mode=WAL;
@ -164,7 +166,7 @@ class SQLiteStorage(object):
timestamp integer,
primary key (sd_hash, reflector_address)
);
"""
""" + SQLiteWalletStorage.CREATE_TABLES_QUERY
def __init__(self, db_dir, reactor=None):
if not reactor:
@ -209,6 +211,12 @@ class SQLiteStorage(object):
else:
defer.returnValue([])
def run_and_return_id(self, query, *args):
def do_save(t):
t.execute(query, args)
return t.lastrowid
return self.db.runInteraction(do_save)
def stop(self):
if self.check_should_announce_lc and self.check_should_announce_lc.running:
self.check_should_announce_lc.stop()
@ -490,14 +498,10 @@ class SQLiteStorage(object):
defer.returnValue(result)
def save_published_file(self, stream_hash, file_name, download_directory, data_payment_rate, status="stopped"):
def do_save(db_transaction):
db_transaction.execute(
"insert into file values (?, ?, ?, ?, ?)",
(stream_hash, file_name, download_directory, data_payment_rate, status)
)
file_rowid = db_transaction.lastrowid
return file_rowid
return self.db.runInteraction(do_save)
return self.run_and_return_id(
"insert into file values (?, ?, ?, ?, ?)",
stream_hash, file_name, download_directory, data_payment_rate, status
)
def get_filename_for_rowid(self, rowid):
return self.run_and_return_one_or_none("select file_name from file where rowid=?", rowid)