Explorar el Código

fu: handle events with no `info` field

epiphany hace 8 meses
padre
commit
c6f3ead63e
Se han modificado 1 ficheros con 11 adiciones y 4 borrados
  1. 11 4
      bin/fud/fu/src/main.rs

+ 11 - 4
bin/fud/fu/src/main.rs

@@ -254,8 +254,12 @@ impl Fu {
             match subscription.receive().await {
                 JsonResult::Notification(n) => {
                     let params = n.params.get::<HashMap<String, JsonValue>>().unwrap();
-                    let info =
-                        params.get("info").unwrap().get::<HashMap<String, JsonValue>>().unwrap();
+                    let info = params.get("info");
+                    if info.is_none() {
+                        continue
+                    }
+                    let info = info.unwrap().get::<HashMap<String, JsonValue>>().unwrap();
+
                     let hash = match info.get("hash") {
                         Some(hash_value) => hash_value.get::<String>().unwrap(),
                         None => continue,
@@ -725,8 +729,11 @@ impl Fu {
             match subscription.receive().await {
                 JsonResult::Notification(n) => {
                     let params = n.params.get::<HashMap<String, JsonValue>>().unwrap();
-                    let info =
-                        params.get("info").unwrap().get::<HashMap<String, JsonValue>>().unwrap();
+                    let info = params.get("info");
+                    if info.is_none() {
+                        continue
+                    }
+                    let info = info.unwrap().get::<HashMap<String, JsonValue>>().unwrap();
                     match params.get("event").unwrap().get::<String>().unwrap().as_str() {
                         "download_started" |
                         "metadata_download_completed" |