From 70b08c49525abeed6848bdb5e42afdbc7b1d05c6 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sun, 24 Feb 2019 20:16:53 +0100 Subject: [PATCH] Get rid of broken JSON migration support (#1113) --- telethon/sessions/sqlite.py | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/telethon/sessions/sqlite.py b/telethon/sessions/sqlite.py index f01843dc..a09e768a 100644 --- a/telethon/sessions/sqlite.py +++ b/telethon/sessions/sqlite.py @@ -1,8 +1,5 @@ import datetime -import json import os -from base64 import b64decode -from os.path import isfile as file_exists from telethon.tl import types from .memory import MemorySession, _SentFileType @@ -45,10 +42,6 @@ class SQLiteSession(MemorySession): if not self.filename.endswith(EXTENSION): self.filename += EXTENSION - # Migrating from .json -> SQL - # TODO ^ Deprecate - entities = self._check_migrate_json() - self._conn = None c = self._cursor() c.execute("select name from sqlite_master " @@ -112,12 +105,6 @@ class SQLiteSession(MemorySession): )""" ) c.execute("insert into version values (?)", (CURRENT_VERSION,)) - # Migrating from JSON -> new table and may have entities - if entities: - c.executemany( - 'insert or replace into entities values (?,?,?,?,?)', - entities - ) self._update_session_table() c.close() self.save() @@ -127,29 +114,6 @@ class SQLiteSession(MemorySession): cloned.save_entities = self.save_entities return cloned - def _check_migrate_json(self): - if file_exists(self.filename): - try: - with open(self.filename, 'r', encoding='utf-8') as f: - data = json.load(f) - self.delete() # Delete JSON file to create database - - self._port = data.get('port', self._port) - self._server_address = \ - data.get('server_address', self._server_address) - - if data.get('auth_key_data', None) is not None: - key = b64decode(data['auth_key_data']) - self._auth_key = AuthKey(data=key) - - rows = [] - for p_id, p_hash in data.get('entities', []): - if p_hash is not None: - rows.append((p_id, p_hash, None, None, None)) - return rows - except UnicodeDecodeError: - return [] # No entities - def _upgrade_database(self, old): c = self._cursor() if old == 1: