mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-10 04:22:13 +10:00
* refactor: Rename StoredManifest to DropData Signed-off-by: quexeky <git@quexeky.dev> * fix: Downloads when resuming would truncate files which had not been finished Signed-off-by: quexeky <git@quexeky.dev> * chore: Didn't import debug macro Signed-off-by: quexeky <git@quexeky.dev> * fix: Download chunks with wrong indexes Migrated to using checksums as indexes instead Signed-off-by: quexeky <git@quexeky.dev> * feat: Resume download button Also added DBWrite and DBRead structs to make database management easier Signed-off-by: quexeky <git@quexeky.dev> * feat: Download resuming Signed-off-by: quexeky <git@quexeky.dev> * feat: Resume button and PartiallyInstalled status Signed-off-by: quexeky <git@quexeky.dev> * feat: Download validation Signed-off-by: quexeky <git@quexeky.dev> * chore: Ran cargo fix & cargo fmt Signed-off-by: quexeky <git@quexeky.dev> * fix: download validation, installs, etc * chore: version bump --------- Signed-off-by: quexeky <git@quexeky.dev> Co-authored-by: quexeky <git@quexeky.dev>
45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
use std::sync::Mutex;
|
|
|
|
use log::{debug, warn};
|
|
use serde::Deserialize;
|
|
use url::Url;
|
|
|
|
use crate::{
|
|
database::db::borrow_db_mut_checked, error::remote_access_error::RemoteAccessError, AppState,
|
|
AppStatus,
|
|
};
|
|
|
|
#[derive(Deserialize)]
|
|
#[serde(rename_all = "camelCase")]
|
|
struct DropHealthcheck {
|
|
app_name: String,
|
|
}
|
|
|
|
pub fn use_remote_logic(
|
|
url: String,
|
|
state: tauri::State<'_, Mutex<AppState<'_>>>,
|
|
) -> Result<(), RemoteAccessError> {
|
|
debug!("connecting to url {}", url);
|
|
let base_url = Url::parse(&url)?;
|
|
|
|
// Test Drop url
|
|
let test_endpoint = base_url.join("/api/v1")?;
|
|
let response = reqwest::blocking::get(test_endpoint.to_string())?;
|
|
|
|
let result: DropHealthcheck = response.json()?;
|
|
|
|
if result.app_name != "Drop" {
|
|
warn!("user entered drop endpoint that connected, but wasn't identified as Drop");
|
|
return Err(RemoteAccessError::InvalidEndpoint);
|
|
}
|
|
|
|
let mut app_state = state.lock().unwrap();
|
|
app_state.status = AppStatus::SignedOut;
|
|
drop(app_state);
|
|
|
|
let mut db_state = borrow_db_mut_checked();
|
|
db_state.base_url = base_url.to_string();
|
|
|
|
Ok(())
|
|
}
|