-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added placeholders for new dedupe code.
- Loading branch information
Showing
6 changed files
with
86 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use clap::Arg; | ||
|
||
pub fn dd_type() -> Arg { | ||
Arg::new("type") | ||
.help("The type of deduplication to perform") | ||
.short('t') | ||
.long("type") | ||
.env("RUXAK_DEDUPE_TYPE") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
//! # (a support module) | ||
pub mod db; | ||
pub mod dedupe; | ||
pub mod record; | ||
pub mod top; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
//! # Deduplicating Records | ||
//! | ||
//! To combine all separate records that have the same data, converting them | ||
//! instead to history entries for one record: | ||
//! | ||
//! ```shell | ||
//! rucksack dedupe --type exact | ||
//! ``` | ||
//! | ||
//! The dedupe type `exact` is the safest and thus the default type, so the above | ||
//! may be executed more succinctly with: | ||
//! | ||
//! ```shell | ||
//! rucksack dedupe | ||
//! ``` | ||
//! | ||
//! To combine records that differ only by password, converting them to history | ||
//! entries of one (the oldest) record and to set the most recent (timestamp) | ||
//! as current: | ||
//! | ||
//! ```shell | ||
//! rucksack deduple --type updated | ||
//! ``` | ||
// use anyhow::{anyhow, Result}; | ||
use anyhow::Result; | ||
use clap::ArgMatches; | ||
|
||
// use rucksack_db as store; | ||
use rucksack_db::db::DB; | ||
// use rucksack_db::records; | ||
|
||
use crate::app::App; | ||
// use crate::input::{query, Flag}; | ||
|
||
pub fn new(matches: &ArgMatches, app: &App) -> Result<()> { | ||
match matches.get_one::<String>("type").map(|s| s.as_str()) { | ||
Some("exact") => dedupe_exact(matches, &app.db)?, | ||
Some("updated") => dedupe_passwords_updated(matches, &app.db)?, | ||
Some("all") => dedupe_all(matches, &app.db)?, | ||
Some("") => dedupe_exact(matches, &app.db)?, | ||
Some(_) => todo!(), | ||
None => dedupe_exact(matches, &app.db)?, | ||
}; | ||
app.db.close()?; | ||
Ok(()) | ||
} | ||
|
||
fn dedupe_exact(_matches: &ArgMatches, _db: &DB) -> Result<(), anyhow::Error> { | ||
log::debug!("Performing exact record deduplication ..."); | ||
Ok(()) | ||
} | ||
|
||
fn dedupe_passwords_updated(_matches: &ArgMatches, _db: &DB) -> Result<(), anyhow::Error> { | ||
log::debug!("Performing updated password record deduplication ..."); | ||
Ok(()) | ||
} | ||
|
||
fn dedupe_all(matches: &ArgMatches, db: &DB) -> Result<(), anyhow::Error> { | ||
dedupe_exact(matches, db)?; | ||
dedupe_passwords_updated(matches, db)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters