💚 End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Address CLI concordance findings and login feedback
Manav Rathifeb262c026bc
diff --git a/rust/Cargo.lock b/rust/Cargo.lockindex 702cd936f6..6ff2ffd653 100644--- a/rust/Cargo.lock+++ b/rust/Cargo.lock@@ -2542,9 +2542,11 @@ dependencies = ["ente-photos","ente-photos-export","ente-test-support",+ "env_logger 0.11.11","futures-util","keyring","mockito",+ "open","reqwest 0.12.28","rusqlite","same-file",diff --git a/rust/Cargo.toml b/rust/Cargo.tomlindex 84eff01d64..620e9f4259 100644--- a/rust/Cargo.toml+++ b/rust/Cargo.toml@@ -82,6 +82,7 @@ ente-test-support = { path = "crates/test-support" }ente-uniffi-log = { path = "bindings/uniffi/log" }ente-vecdb = { path = "crates/vecdb" }ente-wasm-lib = { path = "bindings/wasm/lib" }+env_logger = { version = "0.11.11", default-features = false }fast_image_resize = { version = "6.1.0", features = ["image"] }flate2 = "1.1.10"flutter_rust_bridge = "=2.13.0"@@ -97,6 +98,7 @@ keyring = { version = "3.6.3", default-features = false }log = "0.4.34"md-5 = "0.11.0"mockito = "1.7.2"+open = "5.4.4"ort = { version = "=2.0.0-rc.13", default-features = false }ort-sys = { version = "=2.0.0-rc.13", default-features = false }quick-xml = "0.42.0"diff --git a/rust/apps/cli-next/Cargo.toml b/rust/apps/cli-next/Cargo.tomlindex a5edfe2f2b..80f4ff093e 100644--- a/rust/apps/cli-next/Cargo.toml+++ b/rust/apps/cli-next/Cargo.toml@@ -21,7 +21,9 @@ ente-core.workspace = trueente-paste.workspace = trueente-photos.workspace = trueente-photos-export.workspace = true+env_logger.workspace = truekeyring = { workspace = true, features = ["apple-native", "windows-native", "linux-native-sync-persistent", "crypto-rust"] }+open.workspace = truereqwest.workspace = truerusqlite = { workspace = true, features = ["bundled-sqlcipher"] }serde.workspace = truediff --git a/rust/apps/cli-next/src/account.rs b/rust/apps/cli-next/src/account.rsindex db27329342..fd856c4e2b 100644--- a/rust/apps/cli-next/src/account.rs+++ b/rust/apps/cli-next/src/account.rs@@ -55,7 +55,7 @@ pub async fn request_otp(options.json,&json!({"email": email, "host": origin, "app": app, "purpose": purpose, "verificationRequested": true}),&format!(- "Verification requested for {}. Check your email.",+ "Verification code sent to {}.",output::escape_controls(&email)),)@@ -122,7 +122,10 @@ pub async fn create(args: CreateArgs, options: &Options) -> Result<(State, usize} else {if interactive {client.send_otp(&email, "signup").await?;- eprintln!("Verification requested. Check your email.");+ eprintln!(+ "Verification code sent to {}.",+ output::escape_controls(&email)+ );}let mut supplied = credentials.as_mut().and_then(|input| input.otp.take());let response = loop {@@ -136,7 +139,7 @@ pub async fn create(args: CreateArgs, options: &Options) -> Result<(State, usizematch client.verify_email(&email, &code, None).await {Ok(response) => break response,Err(ente_accounts::Error::IncorrectEmailVerificationCode) if interactive => {- eprintln!("Incorrect email verification code. Try again.")+ eprintln!("Incorrect verification code. Try again.")}Err(error) => return Err(error.into()),}diff --git a/rust/apps/cli-next/src/login.rs b/rust/apps/cli-next/src/login.rsindex fdf5628223..62ad349e0f 100644--- a/rust/apps/cli-next/src/login.rs+++ b/rust/apps/cli-next/src/login.rs@@ -14,7 +14,7 @@ use zeroize::{Zeroize, ZeroizeOnDrop, Zeroizing};use crate::{api,args::{LoginArgs, Options},- parse_json, read_input,+ output, parse_json, read_input,vault::{Account, AccountKeys, DbKey, State, StoredSession, Vault},};@@ -231,10 +231,12 @@ async fn authenticate(credentials: &mut Credentials,interactive: bool,) -> Result<AuthenticatedAccount> {+ let displayed_email = output::escape_controls(&email);let (mut flow, mut step) = LoginFlow::prepare(client, email).await?;if matches!(step, LoginStep::EmailCode) {if interactive {flow.resend_code(client).await?;+ eprintln!("Verification code sent to {displayed_email}.");} else {ensure!(credentials.otp.is_some(),@@ -254,10 +256,13 @@ async fn authenticate(match flow.submit_code(client, &code).await {Ok(next) => break next,Err(ente_accounts::Error::IncorrectEmailVerificationCode) if interactive => {- eprintln!("Incorrect email verification code. Try again.");+ eprintln!("Incorrect verification code. Try again.");}Err(ente_accounts::Error::EmailVerificationCodeExpired) if interactive => {flow.resend_code(client).await?;+ eprintln!(+ "Verification code expired. A new code has been sent to {displayed_email}."+ );}Err(error) => return Err(error.into()),}@@ -298,15 +303,24 @@ async fn authenticate("passkey login requires an interactive terminal without --input or --no-input");let url = flow.passkey_url(client, "ente-cli://passkey")?;- eprintln!("Open this URL to verify your passkey:\n{url}");+ eprintln!("Opening browser for passkey authentication.");+ if !url::Url::parse(&url).is_ok_and(|url| {+ matches!(url.scheme(), "http" | "https") && open::that(url.as_str()).is_ok()+ }) {+ eprintln!(+ "Could not open the browser. Open this URL to complete passkey authentication:"+ );+ }+ eprintln!("{url}\n");loop {Input::<String>::new()- .with_prompt("Press Enter after completing verification")+ .with_prompt("Press Enter after completing authentication").allow_empty(true).interact_on(&Term::stderr())?;if let Some(next) = flow.poll_passkey(client).await? {break next;}+ eprintln!("Passkey authentication is not complete.");}} else {loop {@@ -319,7 +333,7 @@ async fn authenticate(match flow.submit_code(client, &code).await {Ok(next) => break next,Err(ente_accounts::Error::IncorrectTotp) if interactive => {- eprintln!("Incorrect TOTP code. Try again.");+ eprintln!("Incorrect authenticator code. Try again.");}Err(error) => return Err(error.into()),}diff --git a/rust/apps/cli-next/src/main.rs b/rust/apps/cli-next/src/main.rsindex f5367fcea7..0b45950fb6 100644--- a/rust/apps/cli-next/src/main.rs+++ b/rust/apps/cli-next/src/main.rs@@ -31,6 +31,9 @@ use vault::{Account, State, Vault};#[tokio::main]async fn main() {+ env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn"))+ .format(|out, record| writeln!(out, "{}", record.args()))+ .init();let mut command = args::command();let matches = command.get_matches_mut();let result = if matches.get_flag("help-all") {diff --git a/rust/apps/cli-next/tests/cli/export.rs b/rust/apps/cli-next/tests/cli/export.rsindex 80d768a14d..f992a8bdca 100644--- a/rust/apps/cli-next/tests/cli/export.rs+++ b/rust/apps/cli-next/tests/cli/export.rs@@ -895,7 +895,12 @@ fn export_live_pairs_retry_and_reuse_without_rewriting_unchanged_output() -> Teslet destination = tempfile::tempdir()?;let root = destination.path().join("export");objects.interrupt_reads(1);- let result = export(&home, &root, &[]);+ let output = success(+ home.command(&["photos", "export", root.to_str().unwrap(), "--json"])+ .output()?,+ );+ assert!(String::from_utf8_lossy(&output.stderr).contains("retrying in "));+ let result: Value = serde_json::from_slice(&output.stdout)?;assert_eq!(result["copies"]["completed"], 3);assert_eq!(objects.reads(), 3);for folder in ["Live", "Copies"] {@@ -1331,6 +1336,9 @@ fn export_names_are_portable_and_stable() -> TestResult {("IMG-1.jpg", Some(0), "IMG-1-1.jpg"),("CON.jpg", Some(0), "CON-1.jpg"),("CON.extra.jpg", Some(0), "CON-1.extra.jpg"),+ ("CONIN$.jpg", Some(0), "CONIN$-1.jpg"),+ ("CONOUT$.jpg", Some(0), "CONOUT$-1.jpg"),+ ("NUL .jpg", Some(0), "NUL -1.jpg"),("bad:name.jpg", Some(0), "bad_name.jpg"),("bad_name.jpg", Some(0), "bad_name-1.jpg"),("Straße.jpg", Some(0), "Straße.jpg"),diff --git a/rust/apps/cli/Cargo.toml b/rust/apps/cli/Cargo.tomlindex 44c2dcbbdd..b715df0e12 100644--- a/rust/apps/cli/Cargo.toml+++ b/rust/apps/cli/Cargo.toml@@ -18,11 +18,11 @@ dirs.workspace = trueente-accounts.workspace = trueente-core.workspace = trueente-paste.workspace = true-env_logger = "0.11.11"+env_logger = { workspace = true, features = ["auto-color", "humantime", "regex"] }futures = "0.3.34"indicatif = "0.18.6"log.workspace = true-open = "5.4.4"+open.workspace = truerusqlite = { workspace = true, default-features = true, features = ["serde_json"] }serde.workspace = trueserde_json.workspace = truediff --git a/rust/crates/core/src/http.rs b/rust/crates/core/src/http.rsindex bbc7c64bc3..bd9f722d5b 100644--- a/rust/crates/core/src/http.rs+++ b/rust/crates/core/src/http.rs@@ -454,13 +454,17 @@ whereretry_with_delays(&profile.delays(), operation).await}-pub async fn retry_if<T, E, F, Fut>(operation: F, should_retry: impl Fn(&E) -> bool) -> Result<T, E>+pub async fn retry_if<T, E, F, Fut>(+ profile: RetryProfile,+ operation: F,+ should_retry: impl Fn(&E) -> bool,+) -> Result<T, E>whereE: std::fmt::Display,F: FnMut() -> Fut,Fut: Future<Output = Result<T, E>>,{- retry_operation(&RetryProfile::Interactive.delays(), operation, should_retry).await+ retry_operation(&profile.delays(), operation, should_retry).await}async fn retry_with_delays<T, F, Fut>(delays: &[Duration], mut operation: F) -> Result<T, Error>diff --git a/rust/crates/photos-export/src/names.rs b/rust/crates/photos-export/src/names.rsindex 32215593dc..7f14595b20 100644--- a/rust/crates/photos-export/src/names.rs+++ b/rust/crates/photos-export/src/names.rs@@ -100,8 +100,12 @@ pub fn reserved(name: &str, album: bool) -> bool {fn device(name: &str) -> bool {let folded = folded(name);- let device = folded.split('.').next().unwrap_or_default();- ["con", "prn", "aux", "nul", "clock$"].contains(&device)+ let device = folded+ .split('.')+ .next()+ .unwrap_or_default()+ .trim_end_matches(' ');+ ["con", "prn", "aux", "nul", "clock$", "conin$", "conout$"].contains(&device)|| ["com", "lpt"].iter().any(|prefix| {device.strip_prefix(prefix).is_some_and(|n| {matches!(diff --git a/rust/crates/photos/src/files.rs b/rust/crates/photos/src/files.rsindex 5da18cfd77..637a99af6d 100644--- a/rust/crates/photos/src/files.rs+++ b/rust/crates/photos/src/files.rs@@ -87,6 +87,7 @@ pub async fn download<W: std::io::Write>(use futures_util::StreamExt;http::retry_if(+ http::RetryProfile::Background,|| {let output = output();async move {diff --git a/rust/crates/space/src/client/posts.rs b/rust/crates/space/src/client/posts.rsindex bf5fac9172..eac66c8d26 100644--- a/rust/crates/space/src/client/posts.rs+++ b/rust/crates/space/src/client/posts.rs@@ -96,6 +96,7 @@ impl AccountSpaceCtx {};let path = format!("/spaces/{space_id}/posts");let response = http::retry_if(+ http::RetryProfile::Interactive,|| async {self.api().post(&path)