gardesk/garfield / 6d17a19

Browse files

fix portal response to use proper string array type

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
6d17a19c6d6fc17dc84c03411f8d99a64dc0f371
Parents
587b538
Tree
ec0ddf5

2 changed files

StatusFile+-
M garfield-portal/src/file_chooser.rs 6 1
M garfield-portal/src/request.rs 8 4
garfield-portal/src/file_chooser.rsmodified
@@ -105,6 +105,9 @@ impl FileChooser {
105105
         }
106106
 
107107
         tracing::info!("garfield stdout closed, got {} paths", paths.len());
108
+        for (i, path) in paths.iter().enumerate() {
109
+            tracing::info!("  path[{}]: {:?}", i, path);
110
+        }
108111
 
109112
         // Now remove from manager and check status
110113
         let request = self.request_manager.remove(&handle.as_ref()).await;
@@ -123,7 +126,9 @@ impl FileChooser {
123126
             (ResponseCode::Cancelled as u32, HashMap::new())
124127
         } else {
125128
             tracing::info!("Returning {} selected paths", paths.len());
126
-            (ResponseCode::Success as u32, build_file_chooser_response(paths))
129
+            let response = build_file_chooser_response(paths);
130
+            tracing::info!("Response: {:?}", response);
131
+            (ResponseCode::Success as u32, response)
127132
         }
128133
     }
129134
 
garfield-portal/src/request.rsmodified
@@ -104,14 +104,18 @@ pub enum ResponseCode {
104104
 pub fn build_file_chooser_response(
105105
     paths: Vec<String>,
106106
 ) -> HashMap<String, Value<'static>> {
107
+    use zbus::zvariant::Array;
108
+
107109
     let mut results = HashMap::new();
108110
 
109
-    // Convert paths to file:// URIs
110
-    let uris: Vec<Value> = paths
111
+    // Convert paths to file:// URIs as a proper string array (as)
112
+    let uris: Vec<String> = paths
111113
         .into_iter()
112
-        .map(|p| Value::from(format!("file://{}", p)))
114
+        .map(|p| format!("file://{}", p))
113115
         .collect();
114116
 
115
-    results.insert("uris".to_string(), Value::Array(uris.into()));
117
+    // Create array with proper 's' (string) signature
118
+    let uri_array = Array::from(uris);
119
+    results.insert("uris".to_string(), Value::Array(uri_array));
116120
     results
117121
 }