args: add datapath argument

This will allow us to test cache resets

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin 2024-09-06 21:03:33 -07:00
parent c879982260
commit 8602650278
2 changed files with 16 additions and 4 deletions

View File

@ -581,13 +581,14 @@ impl Damus {
setup_cc(cc, is_mobile, parsed_args.light);
let dbpath = parsed_args
.dbpath
let data_path = parsed_args
.datapath
.unwrap_or(data_path.as_ref().to_str().expect("db path ok").to_string());
let dbpath = parsed_args.dbpath.unwrap_or(data_path.clone());
let _ = std::fs::create_dir_all(dbpath.clone());
let imgcache_dir = data_path.as_ref().join(ImageCache::rel_datadir());
let imgcache_dir = format!("{}/{}", data_path, ImageCache::rel_datadir());
let _ = std::fs::create_dir_all(imgcache_dir.clone());
let mut config = Config::new();
@ -662,7 +663,7 @@ impl Damus {
threads: Threads::default(),
drafts: Drafts::default(),
state: DamusState::Initializing,
img_cache: ImageCache::new(imgcache_dir),
img_cache: ImageCache::new(imgcache_dir.into()),
note_cache: NoteCache::default(),
selected_timeline: 0,
timelines,

View File

@ -15,6 +15,7 @@ pub struct Args {
pub debug: bool,
pub textmode: bool,
pub dbpath: Option<String>,
pub datapath: Option<String>,
}
impl Args {
@ -29,6 +30,7 @@ impl Args {
debug: false,
textmode: false,
dbpath: None,
datapath: None,
};
let mut i = 0;
@ -105,6 +107,15 @@ impl Args {
continue;
};
res.dbpath = Some(path.clone());
} else if arg == "--datapath" {
i += 1;
let path = if let Some(next_arg) = args.get(i) {
next_arg
} else {
error!("datapath argument missing?");
continue;
};
res.datapath = Some(path.clone());
} else if arg == "-r" || arg == "--relay" {
i += 1;
let relay = if let Some(next_arg) = args.get(i) {