File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/wasm_navdata_interface/src/download Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -170,15 +170,22 @@ impl NavdataDownloader {
170
170
}
171
171
// Safe to unwrap since we already checked if it was an error
172
172
let json = json_result. unwrap ( ) ;
173
- let url = json[ "url" ] . as_str ( ) . unwrap_or_default ( ) ;
173
+ let url = json[ "url" ] . as_str ( ) . unwrap_or_default ( ) . to_owned ( ) ;
174
174
175
175
// Check if json has "folder"
176
176
let folder = json[ "folder" ] . as_str ( ) . unwrap_or_default ( ) . to_owned ( ) ;
177
177
178
+ // Make sure we have both a url and a folder
179
+ if url. is_empty ( ) || folder. is_empty ( ) {
180
+ let mut status = self . status . borrow_mut ( ) ;
181
+ * status = DownloadStatus :: Failed ( "URL or folder is empty" . to_string ( ) ) ;
182
+ return ;
183
+ }
184
+
178
185
// Create the request
179
186
let captured_self = self . clone ( ) ;
180
187
println ! ( "[WASM] Creating request" ) ;
181
- match NetworkRequestBuilder :: new ( url)
188
+ match NetworkRequestBuilder :: new ( & url)
182
189
. unwrap ( )
183
190
. with_callback ( move |request, status_code| {
184
191
captured_self. request_finished_callback ( request, status_code, folder)
You can’t perform that action at this time.
0 commit comments