If we've reconnected to another DC during GetFile, ensure we always reconnect to original DC even if there is an exception

This commit is contained in:
Mike Manley 2017-08-11 17:46:56 -07:00
parent 133b9fdf6c
commit 4146459be2

View file

@ -329,20 +329,24 @@ namespace TLSharp.Core
var serverPort = _session.Port;
await ReconnectToDcAsync(ex.DC);
var auth = await SendRequestAsync<TLAuthorization>(new TLRequestImportAuthorization
{
bytes = exportedAuth.bytes,
id = exportedAuth.id
});
result = await GetFile(location, filePartSize, offset);
_session.AuthKey = authKey;
_session.TimeOffset = timeOffset;
_transport = new TcpTransport(serverAddress, serverPort);
_session.ServerAddress = serverAddress;
_session.Port = serverPort;
await ConnectAsync();
try
{
var auth = await SendRequestAsync<TLAuthorization>(new TLRequestImportAuthorization
{
bytes = exportedAuth.bytes,
id = exportedAuth.id
});
result = await GetFile(location, filePartSize, offset);
}
finally
{
_session.AuthKey = authKey;
_session.TimeOffset = timeOffset;
_transport = new TcpTransport(serverAddress, serverPort);
_session.ServerAddress = serverAddress;
_session.Port = serverPort;
await ConnectAsync();
}
}
return result;