Skip to content

Commit f95eb33

Browse files
authored
Merge pull request #680 from joshuachp/push-oollvopvqlyn
feat(fileTransfer): add a file store module to read and write files
2 parents 2078ec1 + fe8bd81 commit f95eb33

File tree

8 files changed

+622
-20
lines changed

8 files changed

+622
-20
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 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"] }
@@ -123,6 +123,7 @@ edgehog-tls.workspace = true
123123
eyre.workspace = true
124124
futures.workspace = true
125125
hex.workspace = true
126+
pin-project-lite.workspace = true
126127
rustls.workspace = true
127128
serde.workspace = true
128129
serde_json.workspace = true
@@ -133,14 +134,14 @@ tokio-stream.workspace = true
133134
tokio-util = { workspace = true, features = ["rt"] }
134135
toml.workspace = true
135136
tracing.workspace = true
137+
tracing-error.workspace = true
136138
tracing-subscriber = { workspace = true, features = ["env-filter"] }
137139
url.workspace = true
138140
uuid = { workspace = true, features = ["v5", "v4", "serde"] }
139141
wifiscanner = { workspace = true, optional = true }
140142
zbus = { workspace = true, optional = true, default-features = false, features = ["tokio"] }
141143

142144
# C dependencies
143-
aws-lc-rs = { workspace = true, optional = true }
144145
rusqlite = { workspace = true, optional = true }
145146

146147
[dependencies.reqwest]
@@ -210,13 +211,15 @@ indexmap = "2.11.4"
210211
insta = "1.46.3"
211212
itertools = "0.14.0"
212213
mockall = "0.14.0"
214+
pin-project-lite = "0.2.17"
213215
pretty_assertions = "1.4.1"
214216
procfs = "0.18.0"
215217
reqwest = { version = "0.13.1", default-features = false }
216218
rstest = "0.26.1"
217219
# Version required by diesel
218220
rusqlite = "0.36.0"
219221
rustc_version = "0.4.1"
222+
rustix = "1.1.4"
220223
rustls = "0.23.37"
221224
rustls-native-certs = "0.8.1"
222225
rustls-pemfile = "2.2.0"
@@ -234,6 +237,7 @@ tokio-tungstenite = "0.28.0"
234237
tokio-util = "0.7.16"
235238
toml = "1.0.2"
236239
tracing = "0.1.41"
240+
tracing-error = "0.2.1"
237241
tracing-subscriber = "0.3.20"
238242
udev = "0.9.3"
239243
url = "2.5.7"

edgehog-device-runtime-forwarder/src/test_utils.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
// Copyright 2023-2024 SECO Mind Srl
1+
// This file is part of Edgehog.
2+
//
3+
// Copyright 2023, 2024, 2026 SECO Mind Srl
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
//
217
// SPDX-License-Identifier: Apache-2.0
318

419
//! Module containing utility functions and structures to perform integration test of the library.
@@ -316,6 +331,7 @@ impl MockWebSocket {
316331
.await
317332
.expect("failed to accept connection");
318333

334+
#[expect(clippy::result_large_err)]
319335
tokio_tungstenite::accept_hdr_async(stream, |req: &Request, mut res: Response| {
320336
if let Some(h) = req.headers().get("Sec-WebSocket-Protocol") {
321337
res.headers_mut()

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)