Add WebDAV-based settings sync for desktop app, including connection configuration, editor settings, and optional encrypted secrets sync. Also persist WebDAV remember-password preference across sessions.
102 lines
2.6 KiB
Rust
102 lines
2.6 KiB
Rust
pub mod agent_manager;
|
|
pub mod agent_service;
|
|
pub mod ai;
|
|
pub mod cloud_sync;
|
|
pub mod connection;
|
|
pub mod connection_secrets;
|
|
pub mod csv_export;
|
|
pub mod data_compare;
|
|
pub mod data_grid_sql;
|
|
pub mod database_capabilities;
|
|
pub mod database_export;
|
|
pub mod database_search_sql;
|
|
pub mod db;
|
|
pub mod db_admin_sql;
|
|
pub mod external;
|
|
pub mod history;
|
|
pub mod jdbc;
|
|
pub mod models;
|
|
pub mod mongo_ops;
|
|
pub mod object_source_sql;
|
|
pub mod plugins;
|
|
pub mod query;
|
|
pub mod query_cancel;
|
|
pub mod query_execution_sql;
|
|
pub mod query_result_sql;
|
|
pub mod redis_ops;
|
|
pub mod saved_sql;
|
|
pub mod schema;
|
|
pub mod schema_diff;
|
|
pub mod sql;
|
|
pub mod sql_analysis;
|
|
pub mod sql_dialect;
|
|
pub mod sql_editability;
|
|
pub mod storage;
|
|
pub mod table_import;
|
|
pub mod table_structure_sql;
|
|
pub mod text_export;
|
|
pub mod transfer;
|
|
pub mod types;
|
|
pub mod update;
|
|
pub mod xlsx_export;
|
|
|
|
pub const R2_CDN_BASE: &str = "https://dl.dbxio.com/";
|
|
|
|
pub fn download_candidate_urls(github_url: &str, r2_path: &str) -> Vec<String> {
|
|
vec![format!("{R2_CDN_BASE}{r2_path}"), github_url.to_string()]
|
|
}
|
|
|
|
pub async fn race_download(
|
|
client: &reqwest::Client,
|
|
github_url: &str,
|
|
r2_path: &str,
|
|
user_agent: &str,
|
|
) -> Result<reqwest::Response, String> {
|
|
use futures::future::select_ok;
|
|
use std::pin::Pin;
|
|
|
|
let urls = download_candidate_urls(github_url, r2_path);
|
|
let mut futs: Vec<Pin<Box<dyn std::future::Future<Output = Result<reqwest::Response, String>> + Send>>> =
|
|
Vec::with_capacity(urls.len());
|
|
|
|
for url in urls {
|
|
let client = client.clone();
|
|
let ua = user_agent.to_string();
|
|
futs.push(Box::pin(async move {
|
|
client
|
|
.get(&url)
|
|
.header(reqwest::header::USER_AGENT, ua)
|
|
.send()
|
|
.await
|
|
.and_then(|r| r.error_for_status())
|
|
.map_err(|e| format!("{e}"))
|
|
}) as Pin<Box<dyn std::future::Future<Output = Result<reqwest::Response, String>> + Send>>);
|
|
}
|
|
|
|
match select_ok(futs).await {
|
|
Ok((resp, _)) => Ok(resp),
|
|
Err(last_err) => Err(last_err),
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::download_candidate_urls;
|
|
|
|
#[test]
|
|
fn download_candidates_exclude_third_party_github_proxy() {
|
|
let urls = download_candidate_urls(
|
|
"https://github.com/t8y2/dbx/releases/latest/download/latest.json",
|
|
"releases/latest/latest.json",
|
|
);
|
|
|
|
assert_eq!(
|
|
urls,
|
|
vec![
|
|
"https://dl.dbxio.com/releases/latest/latest.json",
|
|
"https://github.com/t8y2/dbx/releases/latest/download/latest.json",
|
|
]
|
|
);
|
|
}
|
|
}
|