crane for cached dep builds, clippy pedantic, extract paths module
This commit is contained in:
parent
4c17146b6f
commit
888eddf093
7 changed files with 167 additions and 80 deletions
|
|
@ -1,4 +1,7 @@
|
|||
use std::path::Path;
|
||||
// Not a module binary, can't use `mod paths` - duplicate the helper.
|
||||
// This is a one-off tool, not worth a shared lib crate for.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use anyhow::Context;
|
||||
use matrix_sdk::{
|
||||
|
|
@ -12,11 +15,17 @@ use tokio::fs;
|
|||
#[derive(Debug, Deserialize)]
|
||||
struct PersistedSession {
|
||||
homeserver: String,
|
||||
db_path: std::path::PathBuf,
|
||||
db_path: PathBuf,
|
||||
user_session: MatrixSession,
|
||||
}
|
||||
|
||||
const STATE_DIR: &str = "/persist/damocles-lab/state";
|
||||
fn session_path() -> PathBuf {
|
||||
if Path::new("/workspace/config.json").exists() {
|
||||
PathBuf::from("/workspace/state/session.json")
|
||||
} else {
|
||||
PathBuf::from("/persist/damocles-lab/state/session.json")
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
|
|
@ -38,7 +47,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
args[2..].join(" ")
|
||||
};
|
||||
|
||||
let session_file = Path::new(STATE_DIR).join("session.json");
|
||||
let session_file = session_path();
|
||||
let data = fs::read_to_string(&session_file)
|
||||
.await
|
||||
.context("no session file - run the daemon first to log in")?;
|
||||
|
|
@ -52,7 +61,6 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
client.restore_session(session.user_session).await?;
|
||||
|
||||
// need at least one sync so the client knows about joined rooms
|
||||
client
|
||||
.sync_once(matrix_sdk::config::SyncSettings::default())
|
||||
.await?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue