aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client
diff options
context:
space:
mode:
authorConrad Ludgate <conradludgate@gmail.com>2022-04-25 07:13:30 +0100
committerGitHub <noreply@github.com>2022-04-25 07:13:30 +0100
commit7f5310a1aa87cb32499e7f50c864fdaa9a82bd53 (patch)
treea1c499f3876d92687f71e72076c3a715d9f16798 /atuin-client
parentRelease v0.9.1 (#338) (diff)
downloadatuin-7f5310a1aa87cb32499e7f50c864fdaa9a82bd53.zip
history list (#340)
Diffstat (limited to 'atuin-client')
-rw-r--r--atuin-client/Cargo.toml6
-rw-r--r--atuin-client/src/api_client.rs2
-rw-r--r--atuin-client/src/history.rs4
-rw-r--r--atuin-client/src/sync.rs9
4 files changed, 17 insertions, 4 deletions
diff --git a/atuin-client/Cargo.toml b/atuin-client/Cargo.toml
index 8b816d0c..01918706 100644
--- a/atuin-client/Cargo.toml
+++ b/atuin-client/Cargo.toml
@@ -16,7 +16,8 @@ sync = [
"urlencoding",
"sodiumoxide",
"reqwest",
- "rust-crypto",
+ "sha2",
+ "hex",
"rmp-serde",
"base64",
]
@@ -56,7 +57,8 @@ reqwest = { version = "0.11", features = [
"json",
"rustls-tls",
], default-features = false, optional = true }
-rust-crypto = { version = "^0.2", optional = true }
+hex = { version = "0.4", optional = true }
+sha2 = { version = "0.10", optional = true }
rmp-serde = { version = "1.0.0", optional = true }
base64 = { version = "0.13.0", optional = true }
diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs
index d907265b..528d1611 100644
--- a/atuin-client/src/api_client.rs
+++ b/atuin-client/src/api_client.rs
@@ -10,10 +10,10 @@ use atuin_common::api::{
AddHistoryRequest, CountResponse, LoginRequest, LoginResponse, RegisterResponse,
SyncHistoryResponse,
};
-use atuin_common::utils::hash_str;
use crate::encryption::{decode_key, decrypt};
use crate::history::History;
+use crate::sync::hash_str;
static APP_USER_AGENT: &str = concat!("atuin/", env!("CARGO_PKG_VERSION"),);
diff --git a/atuin-client/src/history.rs b/atuin-client/src/history.rs
index 6610b988..c7bf6111 100644
--- a/atuin-client/src/history.rs
+++ b/atuin-client/src/history.rs
@@ -45,4 +45,8 @@ impl History {
hostname,
}
}
+
+ pub fn success(&self) -> bool {
+ self.exit == 0 || self.duration == -1
+ }
}
diff --git a/atuin-client/src/sync.rs b/atuin-client/src/sync.rs
index 9e749614..23f552e5 100644
--- a/atuin-client/src/sync.rs
+++ b/atuin-client/src/sync.rs
@@ -3,13 +3,20 @@ use std::convert::TryInto;
use chrono::prelude::*;
use eyre::Result;
-use atuin_common::{api::AddHistoryRequest, utils::hash_str};
+use atuin_common::api::AddHistoryRequest;
use crate::api_client;
use crate::database::Database;
use crate::encryption::{encrypt, load_encoded_key, load_key};
use crate::settings::{Settings, HISTORY_PAGE_SIZE};
+pub fn hash_str(string: &str) -> String {
+ use sha2::{Digest, Sha256};
+ let mut hasher = Sha256::new();
+ hasher.update(string.as_bytes());
+ hex::encode(hasher.finalize())
+}
+
// Currently sync is kinda naive, and basically just pages backwards through
// history. This means newly added stuff shows up properly! We also just use
// the total count in each database to indicate whether a sync is needed.