Moved some files and started skeleton db

This commit is contained in:
2025-08-15 00:55:47 +01:00
parent d168ca88ec
commit 4f095c55ec
4 changed files with 40 additions and 3 deletions

34
scryfall_deser/src/db.rs Normal file
View File

@@ -0,0 +1,34 @@
use dir_spec::Dir;
use sqlite;
use std::fs;
const CACHE_FOLDER: &str = "scryfall_cache";
// NOTE: this should be idempotent
pub fn create_cache_folder() {
let cache_folder = Dir::cache_home();
match cache_folder {
None => {
panic!("Can't find a cache folder - really don't know what the problem is sorry");
}
Some(mut f) => {
f.push(CACHE_FOLDER);
let ret = fs::create_dir(&f);
match ret {
Ok(_) => (),
Err(_e) => {
let err_string = format!(
"Couldn't create folder within your cache folder: {}",
f.display()
);
panic!("{}", err_string);
}
}
}
}
}
pub fn init_db() -> bool {
create_cache_folder();
true
}