change location of dev db and bump version
This commit is contained in:
@ -66,6 +66,7 @@ pub async fn connect_db() -> Result<SqlitePool, SetupError> {
|
||||
.create_if_missing(true);
|
||||
let pool_opts = SqlitePoolOptions::new();
|
||||
let pool: SqlitePool = pool_opts.connect_with(conn_opts).await?;
|
||||
sqlx::migrate!().run(&pool).await?;
|
||||
Ok(pool)
|
||||
}
|
||||
|
||||
@ -74,8 +75,6 @@ async fn setup(app: &mut App) -> Result<(), Box<dyn Error>> {
|
||||
APP.set(app.handle()).unwrap();
|
||||
|
||||
let pool = connect_db().await?;
|
||||
sqlx::migrate!().run(&pool).await?;
|
||||
|
||||
let conf = AppConfig::load(&pool).await?;
|
||||
let session = Session::load(&pool).await?;
|
||||
let srv = Server::new(conf.listen_addr, conf.listen_port, app.handle()).await?;
|
||||
|
@ -2,6 +2,7 @@ use std::net::Ipv4Addr;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use auto_launch::AutoLaunchBuilder;
|
||||
use is_terminal::IsTerminal;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
@ -90,16 +91,17 @@ pub fn set_auto_launch(is_configured: bool) -> Result<(), SetupError> {
|
||||
|
||||
|
||||
pub fn get_or_create_db_path() -> Result<PathBuf, DataDirError> {
|
||||
// debug_assertions doesn't always mean we are running in dev
|
||||
if cfg!(debug_assertions) && std::env::var("HOME").is_ok() {
|
||||
return Ok(PathBuf::from("./creddy.db"));
|
||||
}
|
||||
|
||||
let mut path = dirs::data_dir()
|
||||
.ok_or(DataDirError::NotFound)?;
|
||||
path.push("Creddy");
|
||||
|
||||
std::fs::create_dir_all(&path)?;
|
||||
path.push("creddy.db");
|
||||
if cfg!(debug_assertions) && std::io::stdout().is_terminal() {
|
||||
path.push("creddy.dev.db");
|
||||
}
|
||||
else {
|
||||
path.push("creddy.db");
|
||||
}
|
||||
|
||||
Ok(path)
|
||||
}
|
||||
|
@ -59,16 +59,7 @@ impl Handler {
|
||||
return Ok(())
|
||||
}
|
||||
let base = req_path == b"/creddy/base-credentials";
|
||||
if base {
|
||||
if clients.len() != 1
|
||||
|| clients[0].is_none()
|
||||
|| clients[0].as_ref().unwrap().exe != std::env::current_exe()?
|
||||
{
|
||||
self.stream.write(b"HTTP/1.0 403 Access Denied\r\n\r\n").await?;
|
||||
return Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let req = Request {id: self.request_id, clients, base};
|
||||
self.app.emit_all("credentials-request", &req)?;
|
||||
let starting_visibility = self.show_window()?;
|
||||
|
Reference in New Issue
Block a user