New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't Open SQLite File On Windows #66
Comments
Ok I think I know the issue.. I had to do some hacky stuff to be able to pass the |
You have pub fn get_default_path() -> PathBuf {
let dir = data_local_dir().expect("Failed to get data local directory,\nPlease specify a path at $CONFIG/CuTE/config.toml\nOr with the --db_path={path/to/CuTE.db}");
let dir = dir.join("CuTE");
dir.join("CuTE.db")
} then over here you do this // If it doesn't exist, create it
if let Err(err) = std::fs::create_dir_all(&path) {
std::fs::File::create(&path).expect("failed to create database");
eprintln!("Failed to create CuTE directory: {}", err);
} else {
println!("CuTE directory created at {:?}", path);
} Create Dir All is creating CuTE.db as a folder and then you pass that exact same path to create a file with the same name at the same place for the SOLite3 db. I dont know for sure, but that seems like a windows nightmare. |
If i delete the folder structure there I get this on cargo run
|
Okay i was able to fix this by doing this pub fn get_default_path() -> PathBuf {
let dir = data_local_dir().expect("Failed to get data local directory,\nPlease specify a path at $CONFIG/CuTE/config.toml\nOr with the --db_path={path/to/CuTE.db}");
let dir = dir.join("CuTE");
//dir.join("CuTE.db")
dir
} and then let conn_result = Connection::open_with_flags(
path.join("CuTE.db"),
OpenFlags::SQLITE_OPEN_READ_WRITE
| OpenFlags::SQLITE_OPEN_CREATE
| OpenFlags::SQLITE_OPEN_URI
| OpenFlags::SQLITE_OPEN_NO_MUTEX,
);
let conn;
// We Need To Handle Some Errors Here Related To Opening SQLite3 Database Files
match conn_result {
Ok(connection) => {
conn = connection;
}
Err(e) => {
println!("CuTE Database Error: {:?}", e);
return Err(e);
}
} this correctly creates the db file like we want in the place you want it on windows. However, this revealed another error related to trying to read a config file that doesnt exist. How are we doing that?
|
Ideally we should have a default config file that gets created, probably in the same AppData / .config directory with default settings that make sense on all platforms. |
Well what is supposed to happen, is that it just has a default config struct.. and if it can't find a file in the dir, it should just create the default struct. unless someone runs |
Okay. |
that way it's not required and someone can just use the default config, but if they choose to |
Okay well, for some reason im panicking here if args.contains_id("dump-config") {
let mut config_path: String = args
.get_one::<String>("dump-config")
.expect("Missing dump-config argument")
.to_string();
if !config_path.contains("config.toml") {
config_path.push_str("/config.toml");
}
let config = CuTE_tui::Config::default();
let config = toml::to_string_pretty(&config).expect("Failed to serialize config");
std::fs::write(config_path, config).expect("Failed to write config file");
} just by executing cargo run with no arguments? Wtf. Love clap tho. |
hmm that is weird af.. hold on i am fixing this request body then i'll fix that |
K, then ill pr this smaller fix i made |
Whatever the same issue that was being caused by App tests on our build before, is now happening locally on my machine after I pulled your latest code.
Im getting an error related to the inability to open the SQLite3 file. When I check the directory that its in on Windows C:\Users\username\AppData\Local\CuTE\CuTE.db CuTE.db is showing up as a directory not a SQLite database file.
This is happening on startup before anything happens, its blocking my ability to open the app at all.
The text was updated successfully, but these errors were encountered: