Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add version to download payload #384

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion uplink/src/collector/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::{
};
use std::{io::Write, path::PathBuf};
use anyhow::Context;
use serde_json::Value;
use crate::base::actions::Cancellation;
use crate::uplink_config::{Authentication, Config, DownloaderConfig};
use crate::{base::bridge::BridgeTx, Action, ActionResponse};
Expand Down Expand Up @@ -238,7 +239,14 @@ impl FileDownloader {
return DownloadResult::Err(e.to_string());
}
// Update Action payload with `download_path`, i.e. downloaded file's location in fs
state.current.action.payload = match serde_json::to_string(&state.current.meta) {
state.current.action.payload = match serde_json::to_value(&state.current.meta)
.map(|mut v| {
if let Value::Object(o) = &mut v {
o.insert("firmware_version".to_string(), Value::String(state.current.meta.file_name.clone()));
}
v
})
.and_then(|r| serde_json::to_string(&r)) {
Ok(p) => p,
Err(e) => {
return DownloadResult::Err(e.to_string());
Expand Down
Loading