Skip to content

Commit 8041b69

Browse files
tangyohaHitaloM
andauthored
fix: use get_session to get session when download (#15)
Co-authored-by: Hitalo <hitalo331@outlook.com>
1 parent e933fdf commit 8041b69

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

hydrogram/client.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
)
5050
from hydrogram.handlers.handler import Handler
5151
from hydrogram.methods import Methods
52+
from hydrogram.methods.messages.inline_session import get_session
5253
from hydrogram.session import Auth, Session
5354
from hydrogram.storage import BaseStorage, SQLiteStorage
5455
from hydrogram.types import ListenerTypes, TermsOfService, User
@@ -930,30 +931,8 @@ async def get_file(
930931

931932
dc_id = file_id.dc_id
932933

933-
session = Session(
934-
self,
935-
dc_id,
936-
await Auth(self, dc_id, await self.storage.test_mode()).create()
937-
if dc_id != await self.storage.dc_id()
938-
else await self.storage.auth_key(),
939-
await self.storage.test_mode(),
940-
is_media=True,
941-
)
942-
943934
try:
944-
await session.start()
945-
946-
if dc_id != await self.storage.dc_id():
947-
exported_auth = await self.invoke(
948-
raw.functions.auth.ExportAuthorization(dc_id=dc_id)
949-
)
950-
951-
await session.invoke(
952-
raw.functions.auth.ImportAuthorization(
953-
id=exported_auth.id, bytes=exported_auth.bytes
954-
)
955-
)
956-
935+
session = await get_session(self, dc_id)
957936
r = await session.invoke(
958937
raw.functions.upload.GetFile(
959938
location=location, offset=offset_bytes, limit=chunk_size

news/15.fix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use `get_session` to get session when downloadind files

0 commit comments

Comments
 (0)