Merge branch 'path-fixes' into 'main'

Fixes to database path when using --data opt

See merge request vade/vade-mecum!6
This commit is contained in:
Joe Bellus 2022-02-15 04:05:43 +00:00
commit 873eaad79c
4 changed files with 7 additions and 7 deletions

View File

@ -30,7 +30,7 @@ tokio = { version = "1.16.1", features=["full"] }
base64 = "0.13.0" base64 = "0.13.0"
sqlx = { version = "^0.5", features=["sqlite", "migrate"] } sqlx = { version = "^0.5", features=["sqlite", "migrate"] }
reqwest = { version = "0.11.9", features = ["rustls-tls"], default-features=false } reqwest = { version = "0.11.9", features = ["rustls-tls"], default-features=false }
clap = { version = "3.0.14", features=["cargo", "env"] } clap = { version = "^3.0", features=["cargo", "env"] }
actix-multipart = "0.4.0-beta.13" actix-multipart = "0.4.0-beta.13"
futures = "0.3.21" futures = "0.3.21"

View File

@ -3,4 +3,4 @@ COPY target/x86_64-unknown-linux-musl/release/vade /app/vade
EXPOSE 8089 EXPOSE 8089
WORKDIR app WORKDIR app
RUN mkdir data RUN mkdir data
CMD ./vade --db data/ CMD ./vade --data data/

View File

@ -34,7 +34,6 @@ pub struct AppState {
#[actix_rt::main] #[actix_rt::main]
async fn main() { async fn main() {
let opts = clap::App::new("Vade Mecum") let opts = clap::App::new("Vade Mecum")
.version(crate_version!())
.arg( .arg(
clap::Arg::new("port") clap::Arg::new("port")
.short('p') .short('p')
@ -207,12 +206,12 @@ async fn setup_database(db_path: &str) -> error::Result<DatabaseConnection> {
let db_fname = "data.db"; let db_fname = "data.db";
let full_path = Path::new(db_path).join(db_fname); let full_path = Path::new(db_path).join(db_fname);
if !full_path.exists() { if !full_path.exists() {
std::fs::File::create(db_fname)?; std::fs::File::create(full_path.clone())?;
} }
let pool = let conn = format!("sqlite://{}", full_path.to_str().unwrap());
sqlx::SqlitePool::connect(&format!("sqlite://{}", full_path.to_str().unwrap())).await?; let pool = sqlx::SqlitePool::connect(&conn).await?;
sqlx::migrate!("./migrations").run(&pool).await?; sqlx::migrate!("./migrations").run(&pool).await?;
tracing::info!("Database migrated"); tracing::info!("Database migrated");
Ok(Database::connect("sqlite://data.db").await?) Ok(Database::connect(&conn).await?)
} }

View File

@ -59,6 +59,7 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for EventSession {
} }
} }
#[tracing::instrument(skip(req, stream, state))]
pub async fn event_session_index( pub async fn event_session_index(
req: HttpRequest, req: HttpRequest,
stream: web::Payload, stream: web::Payload,