Fix syncing issues
This commit is contained in:
parent
195aeff39e
commit
6afa75b638
1 changed files with 7 additions and 3 deletions
|
|
@ -477,12 +477,11 @@ async def main():
|
||||||
except (json.JSONDecodeError, KeyError) as e:
|
except (json.JSONDecodeError, KeyError) as e:
|
||||||
print(f"⚠️ Credentials file is empty or corrupted ({e}). Discarding and forcing new login...")
|
print(f"⚠️ Credentials file is empty or corrupted ({e}). Discarding and forcing new login...")
|
||||||
|
|
||||||
# 2. If no session exists or restoration failed, log in and save the credentials
|
# 2. If no session exists or restoration failed, log in and save credentials
|
||||||
if not session_restored:
|
if not session_restored:
|
||||||
print(f"No valid session found. Logging in to {MATRIX_HOMESERVER}...")
|
print(f"No valid session found. Logging in to {MATRIX_HOMESERVER}...")
|
||||||
resp = await client.login(MATRIX_BOT_PASSWORD)
|
resp = await client.login(MATRIX_BOT_PASSWORD)
|
||||||
|
|
||||||
# Create the store directory if it doesn't exist
|
|
||||||
os.makedirs(os.path.dirname(CREDENTIALS_FILE), exist_ok=True)
|
os.makedirs(os.path.dirname(CREDENTIALS_FILE), exist_ok=True)
|
||||||
|
|
||||||
with open(CREDENTIALS_FILE, "w") as f:
|
with open(CREDENTIALS_FILE, "w") as f:
|
||||||
|
|
@ -493,8 +492,13 @@ async def main():
|
||||||
}, f)
|
}, f)
|
||||||
print(f"Logged in and saved credentials for {MATRIX_BOT_USER}.")
|
print(f"Logged in and saved credentials for {MATRIX_BOT_USER}.")
|
||||||
|
|
||||||
|
# Optional: Perform an initial full state sync ONCE on startup
|
||||||
|
print("Performing initial state sync...")
|
||||||
|
await client.sync(full_state=True)
|
||||||
|
|
||||||
|
# Start the continuous sync loop WITHOUT full_state=True and with a 20s timeout
|
||||||
print("Syncing...")
|
print("Syncing...")
|
||||||
await client.sync_forever(timeout=30000, full_state=True)
|
await client.sync_forever(timeout=20000, full_state=False)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue