Compare commits

...

3 commits

Author SHA1 Message Date
j
02c61c6350 move icons.db into library folder 2019-01-18 19:06:39 +05:30
j
37a45bdad9 torrc uses / on windows 2019-01-18 17:15:11 +05:30
j
2d9f5446dc create peers folder if needed 2019-01-18 17:02:44 +05:30
5 changed files with 31 additions and 5 deletions

View file

@ -3,16 +3,16 @@
import os
import sqlite3
from concurrent.futures import ThreadPoolExecutor
import tornado.concurrent
import tornado.gen
import tornado.ioloop
import tornado.web
from concurrent.futures import ThreadPoolExecutor
from tornado.concurrent import run_on_executor
import ox
from settings import icons_db_path, static_path
from settings import static_path
from utils import resize_image, is_svg
import db
@ -125,7 +125,18 @@ class Icons(dict):
c.close()
conn.close()
icons = Icons(icons_db_path)
def get_icons_db_path():
import settings
import shutil
metadata = os.path.join(os.path.expanduser(settings.preferences['libraryPath']), 'Metadata')
ox.makedirs(metadata)
icons_db_path = os.path.join(metadata, 'icons.db')
old_icons_db_path = os.path.join(settings.data_path, 'icons.db')
if not os.path.exists(icons_db_path) and os.path.exists(old_icons_db_path):
print(icons_db_path, icons_db_path)
shutil.move(old_icons_db_path, icons_db_path)
return icons_db_path
def get_icon_sync(id, type_, size):
if size:
@ -211,3 +222,6 @@ class IconHandler(tornado.web.RequestHandler):
if self._finished:
return
self.write(response)
icons = Icons(get_icons_db_path())

View file

@ -210,6 +210,14 @@ def run_scan():
logger.debug('%s items in library without a record', len(missing))
def change_path(old, new):
old_icons = os.path.join(old, 'Metadata', 'icons.db')
new_icons = os.path.join(new, 'Metadata', 'icons.db')
if os.path.exists(old_icons) and not os.path.exists(new_icons):
ox.makedirs(os.path.dirname(new_icons))
shutil.move(old_icons, new_icons)
import item.icons
item.icons.icons = item.icons.Icons(new_icons)
new_books = os.path.join(new, 'Books')
if not os.path.exists(new_books):
ox.makedirs(new)

View file

@ -25,7 +25,6 @@ if not os.path.exists(data_path):
db_path = os.path.join(data_path, 'data.db')
log_path = os.path.join(data_path, 'debug.log')
icons_db_path = os.path.join(data_path, 'icons.db')
ssl_cert_path = os.path.join(data_path, 'node.ssl.crt')
ssl_key_path = os.path.join(data_path, 'tor', 'private_key')

View file

@ -47,6 +47,8 @@ ControlPort 9831
CookieAuthentication 1
'''.strip())
tor_data = os.path.join(settings.data_path, 'TorData')
if sys.platform == 'win32':
tor_data = os.path.normpath(tor_data).replace(os.SEP, '/')
if not os.path.exists(torrc):
with open(torrc, 'w') as fd:
fd.write('''

View file

@ -602,6 +602,9 @@ def migrate_13():
import json
path = os.path.join(settings.data_path, 'peers', '%s.log' % settings.USER_ID)
if not os.path.exists(path):
folder = os.path.dirname(path)
if not os.path.exists(folder):
os.makedirs(folder)
with db.session() as session:
revision = -1
qs = changelog.Changelog.query.filter_by(user_id=settings.USER_ID)