notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 3cbcd98dd43d1d58e38766e0e36195b12766309e
parent de5039fc65596d5a9f4a3cfb0aa87961feacf4d6
Author: William Casarin <jb55@jb55.com>
Date:   Sat,  3 Aug 2024 11:32:56 -0700

arg: add dbpath argument

This is great for testing without using an existing DB

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/app.rs | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/app.rs b/src/app.rs @@ -655,6 +655,7 @@ struct Args { is_mobile: Option<bool>, keys: Vec<Keypair>, light: bool, + dbpath: Option<String>, } fn parse_args(args: &[String]) -> Args { @@ -664,6 +665,7 @@ fn parse_args(args: &[String]) -> Args { is_mobile: None, keys: vec![], light: false, + dbpath: None, }; let mut i = 0; @@ -710,6 +712,15 @@ fn parse_args(args: &[String]) -> Args { } else { error!("failed to parse filter '{}'", filter); } + } else if arg == "--dbpath" { + i += 1; + let path = if let Some(next_arg) = args.get(i) { + next_arg + } else { + error!("dbpath argument missing?"); + continue; + }; + res.dbpath = Some(path.clone()); } else if arg == "-r" || arg == "--relay" { i += 1; let relay = if let Some(next_arg) = args.get(i) { @@ -783,6 +794,12 @@ impl Damus { setup_cc(cc, is_mobile, parsed_args.light); + let dbpath = parsed_args + .dbpath + .unwrap_or(data_path.as_ref().to_str().expect("db path ok").to_string()); + + let _ = std::fs::create_dir_all(dbpath.clone()); + let imgcache_dir = data_path.as_ref().join(ImageCache::rel_datadir()); let _ = std::fs::create_dir_all(imgcache_dir.clone()); @@ -835,7 +852,7 @@ impl Damus { selected_timeline: 0, timelines: parsed_args.timelines, textmode: false, - ndb: Ndb::new(data_path.as_ref().to_str().expect("db path ok"), &config).expect("ndb"), + ndb: Ndb::new(&dbpath, &config).expect("ndb"), account_manager, //compose: "".to_string(), frame_history: FrameHistory::default(),