Warn before watch history is left behind, and re-apply it later (#2)
CI / test (push) Successful in 1m16s

This commit is contained in:
IxianPixel committed 2026-11-06 17:34:22 +00:00
1 parent 2bd4489b1a
commit 8cfa0f05eb
15 files changed
+611 -73

No files matched your search

+13 -4
View File
@@ -44,9 +44,14 @@ fn libs(root: &Path) -> Vec<Lib> {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber_init();
let tmp = tempfile::tempdir()?;
let cloud = tmp.path().join("cloud");
let home = tmp.path().join("home");
// One fixed folder, emptied on each start: a temp folder per run would
// be left behind (hundreds of MB) whenever the demo is killed.
let root = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../target/demo");
let _ = std::fs::remove_dir_all(&root);
std::fs::create_dir_all(&root)?;
let root = root.canonicalize()?;
let cloud = root.join("cloud");
let home = root.join("home");
for r in [&cloud, &home] {
std::fs::create_dir_all(r.join("movies"))?;
std::fs::create_dir_all(r.join("tv"))?;
@@ -82,7 +87,11 @@ async fn main() -> anyhow::Result<()> {
let fake_cloud = Fake::new(libs(&cloud));
let fake_home = Fake::new(libs(&home));
// Bob only has an account on cloud, so his watch history can't follow a
// move to home until one is created there.
fake_cloud.add_user("u2", "Bob");
if let Some(id) = fake_cloud.find("Movie", "Arrival") {
fake_cloud.set_user_data_for("u2", &id, serde_json::json!({"PlaybackPositionTicks": 36_000_000_000i64}));
fake_cloud.set_user_data(&id, serde_json::json!({"Played": true, "PlayCount": 1}));
}
let jf_cloud = fake_cloud.serve().await;
@@ -124,7 +133,7 @@ async fn main() -> anyhow::Result<()> {
axum::serve(listener, jm_server::api::router(state)).await
}));
}
println!("demo media in {}", tmp.path().display());
println!("demo media in {}", root.display());
println!("cloud: http://127.0.0.1:8097 home: http://127.0.0.1:8098 (Ctrl+C to stop)");
tokio::signal::ctrl_c().await?;
Ok(())