mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-20 13:31:00 +03:00
Attempt at making layer migrations more smooth (#158)
This commit is contained in:
parent
9d35a836d1
commit
7844cd358e
|
@ -281,9 +281,14 @@ class MtProtoSender:
|
||||||
|
|
||||||
# Note that this code is IMPORTANT for skipping RPC results of
|
# Note that this code is IMPORTANT for skipping RPC results of
|
||||||
# lost requests (i.e., ones from the previous connection session)
|
# lost requests (i.e., ones from the previous connection session)
|
||||||
|
try:
|
||||||
if not self._process_msg(
|
if not self._process_msg(
|
||||||
inner_msg_id, sequence, reader, updates):
|
inner_msg_id, sequence, reader, updates):
|
||||||
reader.set_position(begin_position + inner_length)
|
reader.set_position(begin_position + inner_length)
|
||||||
|
except:
|
||||||
|
# If any error is raised, something went wrong; skip the packet
|
||||||
|
reader.set_position(begin_position + inner_length)
|
||||||
|
raise
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,9 @@ from os import path
|
||||||
|
|
||||||
# Import some externalized utilities to work with the Telegram types and more
|
# Import some externalized utilities to work with the Telegram types and more
|
||||||
from . import helpers as utils
|
from . import helpers as utils
|
||||||
from .errors import RPCError, FloodWaitError, FileMigrateError
|
from .errors import (
|
||||||
|
RPCError, FloodWaitError, FileMigrateError, TypeNotFoundError
|
||||||
|
)
|
||||||
from .network import authenticator, MtProtoSender, TcpTransport
|
from .network import authenticator, MtProtoSender, TcpTransport
|
||||||
from .utils import get_appropriated_part_size
|
from .utils import get_appropriated_part_size
|
||||||
|
|
||||||
|
@ -140,6 +142,12 @@ class TelegramBareClient:
|
||||||
self.dc_options = result.dc_options
|
self.dc_options = result.dc_options
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
except TypeNotFoundError as e:
|
||||||
|
# This is fine, probably layer migration
|
||||||
|
self._logger.debug('Found invalid item, probably migrating', e)
|
||||||
|
self.disconnect()
|
||||||
|
self.connect(exported_auth=exported_auth)
|
||||||
|
|
||||||
except (RPCError, ConnectionError) as error:
|
except (RPCError, ConnectionError) as error:
|
||||||
# Probably errors from the previous session, ignore them
|
# Probably errors from the previous session, ignore them
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user