aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/import.rs
diff options
context:
space:
mode:
authorEllie Huxtable <e@elm.sh>2021-04-25 18:21:52 +0100
committerGitHub <noreply@github.com>2021-04-25 17:21:52 +0000
commit156893d774b4da5b541fdbb08428f9ec392949a0 (patch)
tree9185d94384aa62eb6eb099ddc4ca9408df6f90d1 /src/command/import.rs
parentAdd to Cargo.toml (diff)
downloadatuin-156893d774b4da5b541fdbb08428f9ec392949a0.zip
Update docs, unify on SQLx, bugfixes (#40)
* Begin moving to sqlx for local too * Stupid scanners should just have a nice cup of tea Random internet shit searching for /.env or whatever * Remove diesel and rusqlite fully
Diffstat (limited to '')
-rw-r--r--src/command/import.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/command/import.rs b/src/command/import.rs
index 56fb30a7..931e7af4 100644
--- a/src/command/import.rs
+++ b/src/command/import.rs
@@ -26,7 +26,7 @@ pub enum Cmd {
}
impl Cmd {
- pub fn run(&self, db: &mut impl Database) -> Result<()> {
+ pub async fn run(&self, db: &mut (impl Database + Send + Sync)) -> Result<()> {
println!(" A'Tuin ");
println!("======================");
println!(" \u{1f30d} ");
@@ -41,19 +41,19 @@ impl Cmd {
if shell.ends_with("/zsh") {
println!("Detected ZSH");
- import_zsh(db)
+ import_zsh(db).await
} else {
println!("cannot import {} history", shell);
Ok(())
}
}
- Self::Zsh => import_zsh(db),
+ Self::Zsh => import_zsh(db).await,
}
}
}
-fn import_zsh(db: &mut impl Database) -> Result<()> {
+async fn import_zsh(db: &mut (impl Database + Send + Sync)) -> Result<()> {
// oh-my-zsh sets HISTFILE=~/.zhistory
// zsh has no default value for this var, but uses ~/.zhistory.
// we could maybe be smarter about this in the future :)
@@ -103,7 +103,7 @@ fn import_zsh(db: &mut impl Database) -> Result<()> {
buf.push(i);
if buf.len() == buf_size {
- db.save_bulk(&buf)?;
+ db.save_bulk(&buf).await?;
progress.inc(buf.len() as u64);
buf.clear();
@@ -111,7 +111,7 @@ fn import_zsh(db: &mut impl Database) -> Result<()> {
}
if !buf.is_empty() {
- db.save_bulk(&buf)?;
+ db.save_bulk(&buf).await?;
progress.inc(buf.len() as u64);
}