Add avatar_sha field to Cache DB

This commit is contained in:
Philipp Hörist 2017-09-16 17:29:34 +02:00
parent 249e26feac
commit 68f13788ed
4 changed files with 24 additions and 3 deletions

View File

@ -1,6 +1,6 @@
import subprocess
__version__ = "0.16.11"
__version__ = "0.16.11.1"
try:
node = subprocess.Popen('git rev-parse --short=12 HEAD', shell=True,

View File

@ -116,6 +116,7 @@ def create_cache_db():
name TEXT,
subscription INTEGER,
ask BOOLEAN,
avatar_sha TEXT,
PRIMARY KEY (account_jid_id, jid_id)
);

View File

@ -979,8 +979,11 @@ class Logger:
if name is None:
name = ''
self.cur.execute('REPLACE INTO roster_entry VALUES(?, ?, ?, ?, ?)',
(account_jid_id, jid_id, name,
self.cur.execute('''
REPLACE INTO roster_entry
(account_jid_id, jid_id, name, subscription, ask)
VALUES(?, ?, ?, ?, ?)''', (
account_jid_id, jid_id, name,
self.convert_human_subscription_values_to_db_api_values(sub),
bool(ask)))
if commit:

View File

@ -240,6 +240,8 @@ class OptionsParser:
self.update_config_to_016104()
if old < [0, 16, 10, 5] and new >= [0, 16, 10, 5]:
self.update_config_to_016105()
if old < [0, 16, 11, 0] and new >= [0, 16, 11, 1]:
self.update_config_to_016111()
app.logger.init_vars()
app.logger.attach_cache_database()
@ -1012,3 +1014,18 @@ class OptionsParser:
app.config.set('muc_restore_timeout', -1)
app.config.set('restore_timeout', -1)
app.config.set('version', '0.16.10.5')
def update_config_to_016111(self):
con = sqlite.connect(logger.CACHE_DB_PATH)
cur = con.cursor()
try:
cur.executescript(
'''
ALTER TABLE roster_entry ADD COLUMN 'avatar_sha' TEXT;
'''
)
con.commit()
except sqlite.OperationalError:
log.exception('Error')
con.close()
app.config.set('version', '0.16.11.1')