fix butler

This commit is contained in:
Nikita Galaiko 2023-10-10 09:30:46 +02:00 committed by GitButler
parent e672fb7fbf
commit 51ec31d820
2 changed files with 14 additions and 8 deletions

View File

@ -3,11 +3,13 @@ use std::path;
use anyhow::{Context, Result};
use git2::Repository;
use gitbutler::{database, gb_repository, project_repository, projects, sessions, storage, users};
use gitbutler::{
database, gb_repository, paths::DataDir, project_repository, projects, sessions, storage, users,
};
pub struct App {
path: path::PathBuf,
local_data_dir: path::PathBuf,
local_data_dir: DataDir,
project: projects::Project,
sessions_db: sessions::Database,
user: Option<users::User>,
@ -29,8 +31,8 @@ impl App {
.context("failed to find project")?;
let user = users_storage.get_user().context("failed to get user")?;
let db_path = std::path::Path::new(&local_data_dir).join("database.sqlite3");
let database = database::Database::try_from(&db_path).context("failed to open database")?;
let database =
database::Database::try_from(&local_data_dir).context("failed to open database")?;
let sessions_db = sessions::Database::from(database);
Ok(Self {
@ -50,7 +52,7 @@ impl App {
&self.path
}
pub fn local_data_dir(&self) -> &path::PathBuf {
pub fn local_data_dir(&self) -> &DataDir {
&self.local_data_dir
}
@ -86,8 +88,8 @@ fn find_git_directory() -> Option<path::PathBuf> {
}
}
fn find_local_data_dir() -> Option<path::PathBuf> {
fn find_local_data_dir() -> Option<DataDir> {
let mut path = dirs::config_dir().unwrap();
path.push("com.gitbutler.app.dev");
Some(path::PathBuf::from(path.to_string_lossy().to_string()))
Some(path::PathBuf::from(path.to_string_lossy().to_string()).into())
}

View File

@ -17,7 +17,11 @@ impl super::RunCommand for Info {
println!("path: {}", app.path().display().to_string().yellow());
println!(
"data_dir: {}",
app.local_data_dir().display().to_string().yellow()
app.local_data_dir()
.to_path_buf()
.display()
.to_string()
.yellow()
);
// find the project in project storage that matches the cwd