rebuild changelog and redownload from peers.
This commit is contained in:
parent
5bb1d4c162
commit
ff5917ade0
9 changed files with 129 additions and 58 deletions
|
|
@ -7,6 +7,7 @@ import os
|
|||
import shutil
|
||||
|
||||
import ox
|
||||
from sqlalchemy.orm import load_only
|
||||
import sqlalchemy as sa
|
||||
|
||||
from changelog import Changelog
|
||||
|
|
@ -182,6 +183,32 @@ class User(db.Model):
|
|||
session.connection().execute(sql.format(oid=self.id, nid=service_id))
|
||||
session.commit()
|
||||
|
||||
def rebuild_changelog(self):
|
||||
Changelog.query.filter_by(user_id=self.id).delete()
|
||||
for item in self.library.get_items().order_by('created'):
|
||||
Changelog.record(self, 'additem', item.id, item.info)
|
||||
Changelog.record(self, 'edititem', item.id, item.meta)
|
||||
lists = []
|
||||
for l in List.query.filter_by(user_id=self.id, type='static').order_by('index_'):
|
||||
if l.name:
|
||||
lists.append(l.name)
|
||||
Changelog.record(self, 'addlist', l.name)
|
||||
items = [i.id for i in l.get_items().options(load_only('id'))]
|
||||
if items:
|
||||
Changelog.record(self, 'addlistitems', l.name, items)
|
||||
if len(lists) > 1:
|
||||
Changelog.record(self, 'orderlists', lists)
|
||||
|
||||
for peer in User.query.filter_by(peered=True):
|
||||
Changelog.record(self, 'addpeer', peer.id, self.nickname)
|
||||
if peer.info.get('contact'):
|
||||
Changelog.record(self, 'editpeer', peer.id, {
|
||||
'contact': peer.info.get('contact')
|
||||
})
|
||||
|
||||
if settings.preferences.get('contact'):
|
||||
Changelog.record(self, 'editcontact', settings.preferences.get('contact'))
|
||||
|
||||
list_items = sa.Table('listitem', db.metadata,
|
||||
sa.Column('list_id', sa.Integer(), sa.ForeignKey('list.id')),
|
||||
sa.Column('item_id', sa.String(32), sa.ForeignKey('item.id'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue