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

+34 -4
View File
@@ -47,6 +47,8 @@ pub struct Fake {
items: Arc<Mutex<Vec<FakeItem>>>,
/// (user id, item id) → UserData JSON
pub user_data: Arc<Mutex<HashMap<(String, String), Value>>>,
/// (user id, name)
users: Arc<Mutex<Vec<(String, String)>>>,
}
pub fn id_for(path: &Path) -> String {
@@ -103,6 +105,7 @@ impl Fake {
libs: Arc::new(libs),
items: Default::default(),
user_data: Default::default(),
users: Arc::new(Mutex::new(vec![("u1".into(), "Alice".into())])),
};
f.scan();
f
@@ -258,6 +261,25 @@ impl Fake {
.map(|i| i.id.clone())
}
pub fn add_user(&self, id: &str, name: &str) {
self.users.lock().unwrap().push((id.into(), name.into()));
}
pub fn set_user_data_for(&self, user: &str, item: &str, data: Value) {
self.user_data
.lock()
.unwrap()
.insert((user.into(), item.into()), data);
}
pub fn get_user_data_for(&self, user: &str, item: &str) -> Option<Value> {
self.user_data
.lock()
.unwrap()
.get(&(user.to_string(), item.to_string()))
.cloned()
}
pub fn set_user_data(&self, item: &str, data: Value) {
self.user_data
.lock()
@@ -281,10 +303,7 @@ impl Fake {
Json(json!({"ServerName": "fake", "Version": "10.11.0", "Id": "x"}))
}),
)
.route(
"/Users",
get(|| async { Json(json!([{"Id": "u1", "Name": "Alice"}])) }),
)
.route("/Users", get(users))
.route("/Library/VirtualFolders", get(virtual_folders))
.route("/Items", get(items))
.route("/Library/Media/Updated", post(media_updated))
@@ -297,6 +316,17 @@ impl Fake {
}
}
async fn users(State(f): State<Fake>) -> Json<Value> {
Json(Value::Array(
f.users
.lock()
.unwrap()
.iter()
.map(|(id, name)| json!({"Id": id, "Name": name}))
.collect(),
))
}
async fn virtual_folders(State(f): State<Fake>) -> Json<Value> {
Json(Value::Array(
f.libs