diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-07-14 20:44:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-14 20:44:08 +0100 |
| commit | 97e24d0d41bb743833e457de5ba49c5c233eb3b3 (patch) | |
| tree | f0cfefd9048df83d3029cb0b0d21f1f88813fe2e /atuin-client/src/settings.rs | |
| parent | Bump semver from 5.7.1 to 5.7.2 in /docs (#1100) (diff) | |
| download | atuin-97e24d0d41bb743833e457de5ba49c5c233eb3b3.zip | |
Add new sync (#1093)
* Add record migration
* Add database functions for inserting history
No real tests yet :( I would like to avoid running postgres lol
* Add index handler, use UUIDs not strings
* Fix a bunch of tests, remove Option<Uuid>
* Add tests, all passing
* Working upload sync
* Record downloading works
* Sync download works
* Don't waste requests
* Use a page size for uploads, make it variable later
* Aaaaaand they're encrypted now too
* Add cek
* Allow reading tail across hosts
* Revert "Allow reading tail across hosts"
Not like that
This reverts commit 7b0c72e7e050c358172f9b53cbd21b9e44cf4931.
* Handle multiple shards properly
* format
* Format and make clippy happy
* use some fancy types (#1098)
* use some fancy types
* fmt
* Goodbye horrible tuple
* Update atuin-server-postgres/migrations/20230623070418_records.sql
Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
* fmt
* Sort tests too because time sucks
* fix features
---------
Co-authored-by: Conrad Ludgate <conradludgate@gmail.com>
Diffstat (limited to 'atuin-client/src/settings.rs')
| -rw-r--r-- | atuin-client/src/settings.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/atuin-client/src/settings.rs b/atuin-client/src/settings.rs index dd072451..bb41a890 100644 --- a/atuin-client/src/settings.rs +++ b/atuin-client/src/settings.rs @@ -1,8 +1,10 @@ use std::{ io::prelude::*, path::{Path, PathBuf}, + str::FromStr, }; +use atuin_common::record::HostId; use chrono::{prelude::*, Utc}; use clap::ValueEnum; use config::{Config, Environment, File as ConfigFile, FileFormat}; @@ -12,6 +14,7 @@ use parse_duration::parse; use regex::RegexSet; use semver::Version; use serde::Deserialize; +use uuid::Uuid; pub const HISTORY_PAGE_SIZE: i64 = 100; pub const LAST_SYNC_FILENAME: &str = "last_sync_time"; @@ -228,11 +231,13 @@ impl Settings { Settings::load_time_from_file(LAST_VERSION_CHECK_FILENAME) } - pub fn host_id() -> Option<String> { + pub fn host_id() -> Option<HostId> { let id = Settings::read_from_data_dir(HOST_ID_FILENAME); - if id.is_some() { - return id; + if let Some(id) = id { + let parsed = + Uuid::from_str(id.as_str()).expect("failed to parse host ID from local directory"); + return Some(HostId(parsed)); } let uuid = atuin_common::utils::uuid_v7(); @@ -240,7 +245,7 @@ impl Settings { Settings::save_to_data_dir(HOST_ID_FILENAME, uuid.as_simple().to_string().as_ref()) .expect("Could not write host ID to data dir"); - Some(uuid.as_simple().to_string()) + Some(HostId(uuid)) } pub fn should_sync(&self) -> Result<bool> { |
