Skip to content

Commit

Permalink
history list (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate authored Apr 25, 2022
1 parent 2fd9651 commit 7f5310a
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 239 deletions.
101 changes: 6 additions & 95 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ chrono-english = "0.1.4"
cli-table = "0.4"
base64 = "0.13.0"
humantime = "2.1.0"
tabwriter = "1.2.1"
crossbeam-channel = "0.5.1"
clap = { version = "3.1.11", features = ["derive"] }
clap_complete = "3.1.2"
Expand Down
6 changes: 4 additions & 2 deletions atuin-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ sync = [
"urlencoding",
"sodiumoxide",
"reqwest",
"rust-crypto",
"sha2",
"hex",
"rmp-serde",
"base64",
]
Expand Down Expand Up @@ -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 }

Expand Down
2 changes: 1 addition & 1 deletion atuin-client/src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),);

Expand Down
4 changes: 4 additions & 0 deletions atuin-client/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ impl History {
hostname,
}
}

pub fn success(&self) -> bool {
self.exit == 0 || self.duration == -1
}
}
9 changes: 8 additions & 1 deletion atuin-client/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion atuin-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ repository = "https://github.com/ellie/atuin"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rust-crypto = "^0.2"
chrono = { version = "0.4", features = ["serde"] }
serde = { version = "1.0.126", features = ["derive"] }
uuid = { version = "1.0", features = ["v4"] }
9 changes: 0 additions & 9 deletions atuin-common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@ use std::path::PathBuf;
use chrono::NaiveDate;
use uuid::Uuid;

pub fn hash_str(string: &str) -> String {
use crypto::digest::Digest;
use crypto::sha2::Sha256;
let mut hasher = Sha256::new();
hasher.input_str(string);

hasher.result_str()
}

pub fn uuid_v4() -> String {
Uuid::new_v4().as_simple().to_string()
}
Expand Down
1 change: 0 additions & 1 deletion atuin-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ serde_json = "1.0.75"
sodiumoxide = "0.2.6"
base64 = "0.13.0"
rand = "0.8.4"
rust-crypto = "^0.2"
tokio = { version = "1", features = ["full"] }
sqlx = { version = "0.5", features = [ "runtime-tokio-rustls", "chrono", "postgres" ] }
async-trait = "0.1.49"
Expand Down
Loading

0 comments on commit 7f5310a

Please sign in to comment.