Skip to content

Commit 1b1b9f9

Browse files
committed
feat(fileTransfer): add a file store module to read and write files
Signed-off-by: Joshua Chapman <joshua.chapman@secomind.com>
1 parent b76cb0e commit 1b1b9f9

File tree

9 files changed

+677
-52
lines changed

9 files changed

+677
-52
lines changed

Cargo.lock

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ webpki-roots = [
100100
vendored = ["edgehog-store/vendored"]
101101
# Recreates the C bindings at buildtime, requires cmake, clang, and bindgen-cli
102102
bindgen = [
103-
"dep:aws-lc-rs",
104103
"aws-lc-rs/bindgen",
105104
"edgehog-store?/bindgen",
106105
]
@@ -110,6 +109,7 @@ cross = ["vendored", "bindgen"]
110109

111110
[dependencies]
112111
astarte-device-sdk = { workspace = true, features = ["derive"] }
112+
aws-lc-rs.workspace = true
113113
bytes.workspace = true
114114
cfg-if.workspace = true
115115
clap = { workspace = true, features = ["derive", "env"] }
@@ -122,6 +122,8 @@ edgehog-store = { workspace = true, optional = true }
122122
edgehog-tls.workspace = true
123123
eyre.workspace = true
124124
futures.workspace = true
125+
hex.workspace = true
126+
pin-project-lite.workspace = true
125127
rustls.workspace = true
126128
serde.workspace = true
127129
serde_json.workspace = true
@@ -132,14 +134,14 @@ tokio-stream.workspace = true
132134
tokio-util = { workspace = true, features = ["rt"] }
133135
toml.workspace = true
134136
tracing.workspace = true
137+
tracing-error.workspace = true
135138
tracing-subscriber = { workspace = true, features = ["env-filter"] }
136139
url.workspace = true
137140
uuid = { workspace = true, features = ["v5", "v4", "serde"] }
138141
wifiscanner = { workspace = true, optional = true }
139142
zbus = { workspace = true, optional = true, default-features = false, features = ["tokio"] }
140143

141144
# C dependencies
142-
aws-lc-rs = { workspace = true, optional = true }
143145
rusqlite = { workspace = true, optional = true }
144146

145147
[dependencies.reqwest]
@@ -209,13 +211,15 @@ indexmap = "2.11.4"
209211
insta = "1.46.3"
210212
itertools = "0.14.0"
211213
mockall = "0.14.0"
214+
pin-project-lite = "0.2.17"
212215
pretty_assertions = "1.4.1"
213216
procfs = "0.18.0"
214217
reqwest = { version = "0.13.1", default-features = false }
215218
rstest = "0.26.1"
216219
# Version required by diesel
217220
rusqlite = "0.36.0"
218221
rustc_version = "0.4.1"
222+
rustix = "1.1.4"
219223
rustls = "0.23.32"
220224
rustls-native-certs = "0.8.1"
221225
rustls-pemfile = "2.2.0"
@@ -233,6 +237,7 @@ tokio-tungstenite = "0.28.0"
233237
tokio-util = "0.7.16"
234238
toml = "1.0.2"
235239
tracing = "0.1.41"
240+
tracing-error = "0.2.1"
236241
tracing-subscriber = "0.3.20"
237242
udev = "0.9.3"
238243
url = "2.5.7"

snapshots/edgehog_device_runtime__file_transfer__interface__tests__from_and_to_event_download.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ AstarteObject {
3838
"tar.gz",
3939
),
4040
),
41+
(
42+
"fileSizeBytes",
43+
LongInteger(
44+
4096,
45+
),
46+
),
4147
(
4248
"progress",
4349
Boolean(

src/controller/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ impl<C> Runtime<C> {
110110

111111
tasks.spawn(telemetry.spawn(telemetry_rx));
112112

113-
let file_transfer = Self::file_transfer(tasks);
113+
// TODO: Add configuration
114+
let file_transfer = Self::file_transfer(tasks, opts.store_directory.join("file-store"));
114115

115116
#[cfg(feature = "containers")]
116117
let containers_tx = Self::setup_containers(
@@ -153,10 +154,13 @@ impl<C> Runtime<C> {
153154
})
154155
}
155156

156-
fn file_transfer(tasks: &mut JoinSet<eyre::Result<()>>) -> mpsc::Sender<FileTransferEvent> {
157+
fn file_transfer(
158+
tasks: &mut JoinSet<eyre::Result<()>>,
159+
store_dir: std::path::PathBuf,
160+
) -> mpsc::Sender<FileTransferEvent> {
157161
let (tx, rx) = mpsc::channel(EVENT_BUFFER);
158162

159-
tasks.spawn(FileTransfer::new().spawn(rx));
163+
tasks.spawn(FileTransfer::new(store_dir).spawn(rx));
160164

161165
tx
162166
}

0 commit comments

Comments
 (0)