Skip to content

Commit db96e44

Browse files
committed
refactor: make folder a required parameter for downloading
1 parent 86e5ca7 commit db96e44

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/wasm_navdata_interface/src/download/downloader.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,22 @@ impl NavdataDownloader {
170170
}
171171
// Safe to unwrap since we already checked if it was an error
172172
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();
174174

175175
// Check if json has "folder"
176176
let folder = json["folder"].as_str().unwrap_or_default().to_owned();
177177

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+
178185
// Create the request
179186
let captured_self = self.clone();
180187
println!("[WASM] Creating request");
181-
match NetworkRequestBuilder::new(url)
188+
match NetworkRequestBuilder::new(&url)
182189
.unwrap()
183190
.with_callback(move |request, status_code| {
184191
captured_self.request_finished_callback(request, status_code, folder)

0 commit comments

Comments
 (0)