Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions hydrogram/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
)
from hydrogram.handlers.handler import Handler
from hydrogram.methods import Methods
from hydrogram.methods.messages.inline_session import get_session
from hydrogram.session import Auth, Session
from hydrogram.storage import BaseStorage, SQLiteStorage
from hydrogram.types import ListenerTypes, TermsOfService, User
Expand Down Expand Up @@ -930,30 +931,8 @@ async def get_file(

dc_id = file_id.dc_id

session = Session(
self,
dc_id,
await Auth(self, dc_id, await self.storage.test_mode()).create()
if dc_id != await self.storage.dc_id()
else await self.storage.auth_key(),
await self.storage.test_mode(),
is_media=True,
)

try:
await session.start()

if dc_id != await self.storage.dc_id():
exported_auth = await self.invoke(
raw.functions.auth.ExportAuthorization(dc_id=dc_id)
)

await session.invoke(
raw.functions.auth.ImportAuthorization(
id=exported_auth.id, bytes=exported_auth.bytes
)
)

session = await get_session(self, dc_id)
r = await session.invoke(
raw.functions.upload.GetFile(
location=location, offset=offset_bytes, limit=chunk_size
Expand Down
1 change: 1 addition & 0 deletions news/15.fix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use `get_session` to get session when downloadind files