forked from LBRYCommunity/lbry-sdk
make sure blobfiles directory is created in console, and make sure blobfiles dir is always inside the db dir for the gui
This commit is contained in:
parent
8a5a66a06a
commit
5300fa929b
3 changed files with 25 additions and 32 deletions
|
@ -133,6 +133,9 @@ class LBRYConsole():
|
||||||
db_revision.write(str(self.current_db_revision))
|
db_revision.write(str(self.current_db_revision))
|
||||||
db_revision.close()
|
db_revision.close()
|
||||||
log.debug("Created the db revision file: %s", str(os.path.join(self.db_dir, "db_revision")))
|
log.debug("Created the db revision file: %s", str(os.path.join(self.db_dir, "db_revision")))
|
||||||
|
if not os.path.exists(self.blobfile_dir):
|
||||||
|
os.mkdir(self.blobfile_dir)
|
||||||
|
log.debug("Created the blobfile directory: %s", str(self.blobfile_dir))
|
||||||
|
|
||||||
def _check_db_migration(self):
|
def _check_db_migration(self):
|
||||||
old_revision = 0
|
old_revision = 0
|
||||||
|
|
|
@ -29,8 +29,8 @@ class LBRYDownloader(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.session = None
|
self.session = None
|
||||||
self.known_dht_nodes = [('104.236.42.182', 4000)]
|
self.known_dht_nodes = [('104.236.42.182', 4000)]
|
||||||
self.conf_dir = os.path.join(os.path.expanduser("~"), ".lbrydownloader")
|
self.db_dir = os.path.join(os.path.expanduser("~"), ".lbrydownloader")
|
||||||
self.data_dir = os.path.join(self.conf_dir, "blobfiles")
|
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
|
||||||
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
self.wallet_dir = os.path.join(os.path.expanduser("~"), ".lbrycrd")
|
||||||
self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
|
self.wallet_conf = os.path.join(self.wallet_dir, "lbrycrd.conf")
|
||||||
self.peer_port = 3333
|
self.peer_port = 3333
|
||||||
|
@ -79,7 +79,7 @@ class LBRYDownloader(object):
|
||||||
|
|
||||||
def _check_db_migration(self):
|
def _check_db_migration(self):
|
||||||
old_revision = 0
|
old_revision = 0
|
||||||
db_revision_file = os.path.join(self.conf_dir, "db_revision")
|
db_revision_file = os.path.join(self.db_dir, "db_revision")
|
||||||
if os.path.exists(db_revision_file):
|
if os.path.exists(db_revision_file):
|
||||||
old_revision = int(open(db_revision_file).read().strip())
|
old_revision = int(open(db_revision_file).read().strip())
|
||||||
if old_revision < self.current_db_revision:
|
if old_revision < self.current_db_revision:
|
||||||
|
@ -95,7 +95,7 @@ class LBRYDownloader(object):
|
||||||
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
|
si.dwFlags = subprocess.STARTF_USESHOWWINDOW
|
||||||
si.wShowWindow = subprocess.SW_HIDE
|
si.wShowWindow = subprocess.SW_HIDE
|
||||||
print "trying to run the migrator"
|
print "trying to run the migrator"
|
||||||
migrator_proc = subprocess.Popen([migrator_exe, self.conf_dir, str(old_revision),
|
migrator_proc = subprocess.Popen([migrator_exe, self.db_dir, str(old_revision),
|
||||||
str(self.current_db_revision)], startupinfo=si)
|
str(self.current_db_revision)], startupinfo=si)
|
||||||
print "started the migrator"
|
print "started the migrator"
|
||||||
migrator_proc.wait()
|
migrator_proc.wait()
|
||||||
|
@ -104,7 +104,7 @@ class LBRYDownloader(object):
|
||||||
return threads.deferToThread(run_migrator)
|
return threads.deferToThread(run_migrator)
|
||||||
else:
|
else:
|
||||||
from lbrynet.db_migrator import dbmigrator
|
from lbrynet.db_migrator import dbmigrator
|
||||||
return threads.deferToThread(dbmigrator.migrate_db, self.conf_dir, old_revision,
|
return threads.deferToThread(dbmigrator.migrate_db, self.db_dir, old_revision,
|
||||||
self.current_db_revision)
|
self.current_db_revision)
|
||||||
return defer.succeed(True)
|
return defer.succeed(True)
|
||||||
|
|
||||||
|
@ -157,12 +157,10 @@ class LBRYDownloader(object):
|
||||||
raise ValueError("run_server must be set to True or False. Got %s" % field_value)
|
raise ValueError("run_server must be set to True or False. Got %s" % field_value)
|
||||||
log.debug("Setting run_server to %s", str(run_server))
|
log.debug("Setting run_server to %s", str(run_server))
|
||||||
self.run_server = run_server
|
self.run_server = run_server
|
||||||
elif field_name == "db_dir":
|
|
||||||
log.debug("Setting conf_dir to %s", str(field_value))
|
|
||||||
self.conf_dir = field_value
|
|
||||||
elif field_name == "data_dir":
|
elif field_name == "data_dir":
|
||||||
log.debug("Setting data_dir to %s", str(field_value))
|
log.debug("Setting data_dir to %s", str(field_value))
|
||||||
self.data_dir = field_value
|
self.db_dir = field_value
|
||||||
|
self.blobfile_dir = os.path.join(self.db_dir, "blobfiles")
|
||||||
elif field_name == "wallet_dir":
|
elif field_name == "wallet_dir":
|
||||||
log.debug("Setting wallet_dir to %s", str(field_value))
|
log.debug("Setting wallet_dir to %s", str(field_value))
|
||||||
self.wallet_dir = field_value
|
self.wallet_dir = field_value
|
||||||
|
@ -228,15 +226,15 @@ class LBRYDownloader(object):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _create_directory(self):
|
def _create_directory(self):
|
||||||
if not os.path.exists(self.conf_dir):
|
if not os.path.exists(self.db_dir):
|
||||||
os.makedirs(self.conf_dir)
|
os.makedirs(self.db_dir)
|
||||||
db_revision = open(os.path.join(self.conf_dir, "db_revision"), mode='w')
|
db_revision = open(os.path.join(self.db_dir, "db_revision"), mode='w')
|
||||||
db_revision.write(str(self.current_db_revision))
|
db_revision.write(str(self.current_db_revision))
|
||||||
db_revision.close()
|
db_revision.close()
|
||||||
log.debug("Created the configuration directory: %s", str(self.conf_dir))
|
log.debug("Created the configuration directory: %s", str(self.db_dir))
|
||||||
if not os.path.exists(self.data_dir):
|
if not os.path.exists(self.blobfile_dir):
|
||||||
os.makedirs(self.data_dir)
|
os.makedirs(self.blobfile_dir)
|
||||||
log.debug("Created the data directory: %s", str(self.data_dir))
|
log.debug("Created the data directory: %s", str(self.blobfile_dir))
|
||||||
if not os.path.exists(self.wallet_dir):
|
if not os.path.exists(self.wallet_dir):
|
||||||
os.makedirs(self.wallet_dir)
|
os.makedirs(self.wallet_dir)
|
||||||
if not os.path.exists(self.wallet_conf):
|
if not os.path.exists(self.wallet_conf):
|
||||||
|
@ -265,8 +263,8 @@ class LBRYDownloader(object):
|
||||||
peer_port = None
|
peer_port = None
|
||||||
if self.run_server:
|
if self.run_server:
|
||||||
peer_port = self.peer_port
|
peer_port = self.peer_port
|
||||||
self.session = LBRYSession(self.default_blob_data_payment_rate, db_dir=self.conf_dir,
|
self.session = LBRYSession(self.default_blob_data_payment_rate, db_dir=self.db_dir,
|
||||||
blob_dir=self.data_dir, use_upnp=self.use_upnp, wallet=wallet,
|
blob_dir=self.blobfile_dir, use_upnp=self.use_upnp, wallet=wallet,
|
||||||
known_dht_nodes=self.known_dht_nodes, dht_node_port=self.dht_node_port,
|
known_dht_nodes=self.known_dht_nodes, dht_node_port=self.dht_node_port,
|
||||||
peer_port=peer_port)
|
peer_port=peer_port)
|
||||||
return self.session.setup()
|
return self.session.setup()
|
||||||
|
|
|
@ -16,22 +16,14 @@
|
||||||
# download_directory = /path/to/example_directory
|
# download_directory = /path/to/example_directory
|
||||||
|
|
||||||
|
|
||||||
# ===== db_dir =====
|
|
||||||
# The database directory is the directory in which the application
|
|
||||||
# stores information about the encrypted chunks stored on disk
|
|
||||||
# and the streams they belong to, among other things. By default,
|
|
||||||
# set to '.lbrydownloader' in the user's home directory.
|
|
||||||
#
|
|
||||||
# db_dir = /path/to/home/.lbrydownloader
|
|
||||||
|
|
||||||
|
|
||||||
# ===== data_dir =====
|
# ===== data_dir =====
|
||||||
# The data directory is the directory in which the small encrypted
|
# The data directory is the directory in which the application
|
||||||
# chunks of data which constitute files and other streams are
|
# stores information about the encrypted chunks stored on disk
|
||||||
# stored. By default, data_dir is set to the blobfiles subdirectory
|
# and the streams they belong to, the encrypted chunks themselves,
|
||||||
# of the database directory, db_dir.
|
# and any other metadata. By default, set to '.lbrydownloader'
|
||||||
|
# in the user's home directory.
|
||||||
#
|
#
|
||||||
# data_dir = /path/to/home/.lbrydownloader/blobfiles
|
# data_dir = /path/to/home/.lbrydownloader
|
||||||
|
|
||||||
|
|
||||||
# ===== run_server =====
|
# ===== run_server =====
|
||||||
|
|
Loading…
Add table
Reference in a new issue