| + |
use std::path::PathBuf;
|
| + |
|
| + |
use radicle::git;
|
| + |
use radicle::identity::RepoId;
|
| + |
use radicle_types::cobs::release;
|
| + |
use radicle_types::error::Error;
|
| + |
use radicle_types::traits::release::Releases;
|
| + |
use radicle_types::traits::release_mut::ReleasesMut;
|
| + |
|
| + |
use crate::AppState;
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn list_releases(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
) -> Result<Vec<release::Release>, Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.list_releases(rid))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn release_by_id(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
release_id: String,
|
| + |
) -> Result<Option<release::Release>, Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.release_by_id(rid, release_id))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn releases_by_commit(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
sha: git::Oid,
|
| + |
) -> Result<Vec<release::Release>, Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.releases_by_commit(rid, sha))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
/// CID computation can be expensive on large files; off-load to the
|
| + |
/// blocking pool so the IPC thread stays responsive.
|
| + |
#[tauri::command]
|
| + |
pub async fn compute_artifact_cid(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
path: PathBuf,
|
| + |
) -> Result<String, Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.compute_cid(path))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn create_or_open_release(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
oid: git::Oid,
|
| + |
) -> Result<String, Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.create_or_open_release(rid, oid))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn add_artifact(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
release_id: String,
|
| + |
cid: String,
|
| + |
name: String,
|
| + |
) -> Result<(), Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.add_artifact(rid, release_id, cid, name))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn add_location(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
release_id: String,
|
| + |
cid: String,
|
| + |
url: String,
|
| + |
) -> Result<(), Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.add_location(rid, release_id, cid, url))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn remove_location(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
release_id: String,
|
| + |
cid: String,
|
| + |
url: String,
|
| + |
) -> Result<(), Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.remove_location(rid, release_id, cid, url))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn attest_artifact(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
release_id: String,
|
| + |
cid: String,
|
| + |
) -> Result<(), Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || ctx.attest_artifact(rid, release_id, cid))
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub async fn redact_artifact(
|
| + |
ctx: tauri::State<'_, AppState>,
|
| + |
rid: RepoId,
|
| + |
release_id: String,
|
| + |
cid: String,
|
| + |
reason: String,
|
| + |
) -> Result<(), Error> {
|
| + |
let ctx = ctx.inner().clone();
|
| + |
tauri::async_runtime::spawn_blocking(move || {
|
| + |
ctx.redact_artifact(rid, release_id, cid, reason)
|
| + |
})
|
| + |
.await
|
| + |
.map_err(|e| Error::Iroh(format!("join: {e}")))?
|
| + |
}
|
| + |
|
| + |
// Settings ------------------------------------------------------------------
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub fn get_auto_seed_artifacts(ctx: tauri::State<AppState>) -> Result<bool, Error> {
|
| + |
let settings = radicle_types::settings::load(ctx.profile.home().path());
|
| + |
Ok(settings.auto_seed_artifacts)
|
| + |
}
|
| + |
|
| + |
#[tauri::command]
|
| + |
pub fn set_auto_seed_artifacts(
|
| + |
ctx: tauri::State<AppState>,
|
| + |
enabled: bool,
|
| + |
) -> Result<(), Error> {
|
| + |
let mut settings = radicle_types::settings::load(ctx.profile.home().path());
|
| + |
settings.auto_seed_artifacts = enabled;
|
| + |
radicle_types::settings::save(ctx.profile.home().path(), &settings)
|
| + |
}
|