Fixes to database path when using --data opt

This commit is contained in:
Joe Bellus 2022-02-15 04:05:41 +00:00
parent 62bec56241
commit 6cef87d46d
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"
sqlx = { version = "^0.5", features=["sqlite", "migrate"] }
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"
futures = "0.3.21"

View File

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

View File

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