export library.json into data, fixes #82

This commit is contained in:
j 2016-01-20 13:22:00 +05:30
parent d0a9515cc0
commit bae70fd829
2 changed files with 8 additions and 1 deletions

View File

@ -28,7 +28,7 @@ class Downloads(Thread):
if now > settings.server.get('last_update_check', 0) + 24*60*60:
settings.server['last_update_check'] = now
update.download()
state.user().library.export_json()
state.user().export_library()
def download_next(self):
import item.models

View File

@ -92,6 +92,13 @@ class User(db.Model):
j['name'] = self.name
return j
def export_library(self):
old_path = os.path.join(os.path.expanduser(settings.preferences['libraryPath']), 'Books', 'library.json')
if os.path.exists(old_path):
os.unlink(old_path)
path = os.path.join(settings.data_path, 'library.json')
self.library.export_json(path)
def is_online(self):
return state.nodes and state.nodes.is_online(self.id)