move icons.db into library folder
This commit is contained in:
parent
37a45bdad9
commit
02c61c6350
3 changed files with 26 additions and 5 deletions
|
@ -3,16 +3,16 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
import tornado.concurrent
|
import tornado.concurrent
|
||||||
import tornado.gen
|
import tornado.gen
|
||||||
import tornado.ioloop
|
import tornado.ioloop
|
||||||
import tornado.web
|
import tornado.web
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
|
||||||
from tornado.concurrent import run_on_executor
|
from tornado.concurrent import run_on_executor
|
||||||
|
import ox
|
||||||
|
|
||||||
|
from settings import static_path
|
||||||
from settings import icons_db_path, static_path
|
|
||||||
from utils import resize_image, is_svg
|
from utils import resize_image, is_svg
|
||||||
import db
|
import db
|
||||||
|
|
||||||
|
@ -125,7 +125,18 @@ class Icons(dict):
|
||||||
c.close()
|
c.close()
|
||||||
conn.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):
|
def get_icon_sync(id, type_, size):
|
||||||
if size:
|
if size:
|
||||||
|
@ -211,3 +222,6 @@ class IconHandler(tornado.web.RequestHandler):
|
||||||
if self._finished:
|
if self._finished:
|
||||||
return
|
return
|
||||||
self.write(response)
|
self.write(response)
|
||||||
|
|
||||||
|
|
||||||
|
icons = Icons(get_icons_db_path())
|
||||||
|
|
|
@ -210,6 +210,14 @@ def run_scan():
|
||||||
logger.debug('%s items in library without a record', len(missing))
|
logger.debug('%s items in library without a record', len(missing))
|
||||||
|
|
||||||
def change_path(old, new):
|
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')
|
new_books = os.path.join(new, 'Books')
|
||||||
if not os.path.exists(new_books):
|
if not os.path.exists(new_books):
|
||||||
ox.makedirs(new)
|
ox.makedirs(new)
|
||||||
|
|
|
@ -25,7 +25,6 @@ if not os.path.exists(data_path):
|
||||||
|
|
||||||
db_path = os.path.join(data_path, 'data.db')
|
db_path = os.path.join(data_path, 'data.db')
|
||||||
log_path = os.path.join(data_path, 'debug.log')
|
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_cert_path = os.path.join(data_path, 'node.ssl.crt')
|
||||||
ssl_key_path = os.path.join(data_path, 'tor', 'private_key')
|
ssl_key_path = os.path.join(data_path, 'tor', 'private_key')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue