Files
Jellymove/crates/jm-server/src/lib.rs
T
IxianPixel 4c6217bd40
CI / test (push) Successful in 1m18s
Add a Trash view to see and empty .jellymove-trash (#3)
Moved folders sat in each library's .jellymove-trash until removed by hand on the server. The new Trash tab lists them on either server with
size, file count, when and where they went, and empties one item, a library or everything after a confirmation.
- trash.rs: list and empty entries. Entries are referred to by an opaque ID and resolved by scanning; only real folders directly inside a trash folder can be deleted.
- Each move now gets its own trash entry folder, with a small metadata file. Fixes moves failing when the same item had been trashed before.
- Peer API: GET /trash, POST /trash/empty, and /exports/{id}/complete now records the job and destination.
- e2e tests for listing, emptying from either side, refusing paths as IDs, and moving the same item away twice.

Closes #3
2026-11-06 16:30:54 +00:00

60 lines
1.8 KiB
Rust

//! The jellymove daemon: HTTP API, embedded UI, job runner and source exports.
pub mod api;
pub mod config;
pub mod export;
pub mod library;
pub mod peer;
pub mod runner;
pub mod state;
pub mod trash;
pub mod ui;
use std::sync::Arc;
pub use config::Config;
use tower_http::trace::TraceLayer;
/// Open state, resume interrupted jobs and serve until shutdown.
pub async fn run(cfg: Config) -> anyhow::Result<()> {
std::fs::create_dir_all(&cfg.data_dir)?;
let store = jm_store::Store::open(&cfg.data_dir.join("jellymove.db"))?;
let listen = cfg.listen;
let state = Arc::new(state::AppState::new(cfg, store)?);
match state.jellyfin.system_info().await {
Ok(i) => {
tracing::info!(server = %i.server_name, version = %i.version, "connected to Jellyfin")
}
Err(e) => {
tracing::warn!(error = %e, "can't reach Jellyfin yet; will keep trying on demand")
}
}
runner::resume_all(&state).await?;
let app = api::router(state.clone()).layer(TraceLayer::new_for_http());
let listener = tokio::net::TcpListener::bind(listen).await?;
tracing::info!(%listen, node = %state.cfg.node_name, "jellymove listening");
axum::serve(listener, app)
.with_graceful_shutdown(shutdown_signal())
.await?;
Ok(())
}
async fn shutdown_signal() {
let ctrl_c = async {
let _ = tokio::signal::ctrl_c().await;
};
#[cfg(unix)]
let term = async {
if let Ok(mut s) = tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate())
{
s.recv().await;
}
};
#[cfg(not(unix))]
let term = std::future::pending::<()>();
tokio::select! { _ = ctrl_c => {}, _ = term => {} }
tracing::info!("shutting down; in-flight transfers will resume on next start");
}