diff options
| author | Ellie Huxtable <e@elm.sh> | 2021-04-20 21:53:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-20 20:53:07 +0000 |
| commit | a21737e2b7f8d1e426726bdd7536033f299d476a (patch) | |
| tree | e940afdff9c145d25d9a2895fd44a77d70719a2e /atuin-client/src/sync.rs | |
| parent | Switch to Warp + SQLx, use async, switch to Rust stable (#36) (diff) | |
| download | atuin-a21737e2b7f8d1e426726bdd7536033f299d476a.zip | |
Use cargo workspaces (#37)
* Switch to Cargo workspaces
Breaking things into "client", "server" and "common" makes managing the
codebase much easier!
client - anything running on a user's machine for adding history
server - handles storing/syncing history and running a HTTP server
common - request/response API definitions, common utils, etc
* Update dockerfile
Diffstat (limited to '')
| -rw-r--r-- | atuin-client/src/sync.rs (renamed from src/local/sync.rs) | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/local/sync.rs b/atuin-client/src/sync.rs index e0feb759..0ca8d3a6 100644 --- a/src/local/sync.rs +++ b/atuin-client/src/sync.rs @@ -3,11 +3,12 @@ use std::convert::TryInto; use chrono::prelude::*; use eyre::Result; -use crate::local::api_client; -use crate::local::database::Database; -use crate::local::encryption::{encrypt, load_key}; -use crate::settings::{Local, Settings, HISTORY_PAGE_SIZE}; -use crate::{api::AddHistoryRequest, utils::hash_str}; +use atuin_common::{api::AddHistoryRequest, utils::hash_str}; + +use crate::api_client; +use crate::database::Database; +use crate::encryption::{encrypt, load_key}; +use crate::settings::{Settings, HISTORY_PAGE_SIZE}; // Currently sync is kinda naive, and basically just pages backwards through // history. This means newly added stuff shows up properly! We also just use @@ -33,7 +34,7 @@ async fn sync_download( let mut last_sync = if force { Utc.timestamp_millis(0) } else { - Local::last_sync()? + Settings::last_sync()? }; let mut last_timestamp = Utc.timestamp_millis(0); @@ -124,8 +125,8 @@ async fn sync_upload( pub async fn sync(settings: &Settings, force: bool, db: &mut (impl Database + Send)) -> Result<()> { let client = api_client::Client::new( - settings.local.sync_address.as_str(), - settings.local.session_token.as_str(), + settings.sync_address.as_str(), + settings.session_token.as_str(), load_key(settings)?, ); @@ -135,7 +136,7 @@ pub async fn sync(settings: &Settings, force: bool, db: &mut (impl Database + Se debug!("sync downloaded {}", download.0); - Local::save_sync_time()?; + Settings::save_sync_time()?; Ok(()) } |
