print db path for debugging

This commit is contained in:
liyunze 2026-01-06 23:52:46 +08:00
parent 79464d3bfb
commit 0b535d2c4c
2 changed files with 14 additions and 1 deletions

View file

@ -2,4 +2,8 @@ services:
portfolio_roast_bot:
build: .
env_file:
- .env
- .env
environment:
- DATABASE_PATH=/data/bot_data.sqlite
volumes:
- bot_data:/data

View file

@ -5,8 +5,17 @@ use rusqlite::{Connection, OpenFlags, Result};
pub fn init_db() -> Result<Connection, rusqlite::Error> {
let filename = env::var("DATABASE_PATH").unwrap_or_else(|_| "bot_data.sqlite".to_string());
let filepath = Path::new(&filename);
match filepath.canonicalize() {
Ok(abs_path) => println!("Absolute filepath: {:?}", abs_path),
Err(_) => println!(
"Filepath (not yet created): {:?}",
fs::canonicalize(".").unwrap().join(&filename)
),
}
if let Some(parent) = filepath.parent() {
if !parent.as_os_str().is_empty() {
fs::create_dir_all(parent).expect("Failed to create database directory");