Skip to content

Commit 795ffc0

Browse files
authored
Allow non-interactive migration from storage v2 to v3 (#979)
1 parent bbe90fc commit 795ffc0

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

pyrogram/client.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -592,21 +592,24 @@ async def load_session(self):
592592
else:
593593
# Needed for migration from storage v2 to v3
594594
if not await self.storage.api_id():
595-
while True:
596-
try:
597-
value = int(await ainput("Enter the api_id part of the API key: "))
595+
if self.api_id:
596+
await self.storage.api_id(self.api_id)
597+
else:
598+
while True:
599+
try:
600+
value = int(await ainput("Enter the api_id part of the API key: "))
598601

599-
if value <= 0:
600-
print("Invalid value")
601-
continue
602+
if value <= 0:
603+
print("Invalid value")
604+
continue
602605

603-
confirm = (await ainput(f'Is "{value}" correct? (y/N): ')).lower()
606+
confirm = (await ainput(f'Is "{value}" correct? (y/N): ')).lower()
604607

605-
if confirm == "y":
606-
await self.storage.api_id(value)
607-
break
608-
except Exception as e:
609-
print(e)
608+
if confirm == "y":
609+
await self.storage.api_id(value)
610+
break
611+
except Exception as e:
612+
print(e)
610613

611614
def load_plugins(self):
612615
if self.plugins:

0 commit comments

Comments
 (0)