diff --git a/src/main.rs b/src/main.rs index 9fd3284..cce81e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -180,16 +180,11 @@ async fn on_room_message(event: OriginalSyncRoomMessageEvent, room: Room) -> any async fn main() -> anyhow::Result<()> { let args: Vec = std::env::args().collect(); - let data_dir = dirs::data_dir() - .expect("no data_dir directory found") - .join("scam_police"); - let session_file = data_dir.join("session"); - - let (client, sync_token) = if session_file.exists() { - matrix::restore_session(&session_file).await? + let (client, sync_token) = if SESSION_FILE.exists() { + matrix::restore_session(&SESSION_FILE).await? } else if args.len() > 1 { ( - matrix::login(&data_dir, &session_file, args.get(1).unwrap().to_owned()).await?, + matrix::login(&DATA_DIR, &SESSION_FILE, args.get(1).unwrap().to_owned()).await?, None, ) } else { @@ -202,7 +197,7 @@ async fn main() -> anyhow::Result<()> { let (client, sync_settings) = match matrix::sync(client, sync_token).await { Ok(c) => c, Err(e) => { - std::fs::remove_dir_all(data_dir)?; + std::fs::remove_dir_all(DATA_DIR.to_owned())?; anyhow::bail!("{e}"); } };