Add optional --dbpath flag (#6)

* Use common config with lower cache capacity

* Add command line argument parser

* Add optional --dbpath flag
This commit is contained in:
Dave Gallant
2020-06-22 22:54:06 -04:00
committed by GitHub
parent 94863c3c69
commit 1989b48d99
6 changed files with 101 additions and 31 deletions

View File

@@ -73,7 +73,7 @@ fn hash_deal(topic: &Topic) -> String {
hasher.result_str()
}
pub fn match_deals(deals: Deals, config: Config) {
pub fn match_deals(deals: Deals, config: Config, dbpath: &str) {
for topic in deals.topics.iter() {
for expression in config.expressions.iter() {
let mut found_match = false;
@@ -101,7 +101,7 @@ pub fn match_deals(deals: Deals, config: Config) {
continue;
}
let deal_hash = hash_deal(topic);
if db::hash_exists(&deal_hash) {
if db::hash_exists(&deal_hash, db::get_config(dbpath)) {
debug!("deal hash '{}' already exists", &deal_hash);
} else {
let posts = parse_posts(
@@ -110,7 +110,7 @@ pub fn match_deals(deals: Deals, config: Config) {
.ok()
.unwrap(),
);
db::insert(&deal_hash);
db::insert(&deal_hash, db::get_config(dbpath));
mail::send(topic, &posts, expression, &config);
}
}