notedeck

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

commit 86026502788afb12c5c9c223b659e6dfccca29b1
parent c8799822604d610140c74d8d32f65f420c35e1b8
Author: William Casarin <jb55@jb55.com>
Date:   Fri,  6 Sep 2024 21:03:33 -0700

args: add datapath argument

This will allow us to test cache resets

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

Diffstat:
Msrc/app.rs | 9+++++----
Msrc/args.rs | 11+++++++++++
2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/app.rs b/src/app.rs @@ -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, diff --git a/src/args.rs b/src/args.rs @@ -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) {