summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-06-21 08:04:11 +0200
committerMatthias Beyer <matthias.beyer@ifm.com>2022-08-06 09:47:18 +0200
commit229259a38f41fb2686031c4bc7748eea324d8ca4 (patch)
tree1a9d2339183daee06fa11e621325220d0fcd4b89 /crates/core/tedge
parenta9e04b8ba2bd25eb0102ba42cf8c8d05e7d24250 (diff)
Do not necessarily pass &str anymore to fs helper fns
This patch changs the calls of the fs helper functions where the interface of the functions was changed from taking `&str` as path argument to `impl AsRef<Path>`. Because of this, it is not necessary anymore that `&str` is passed, but `Path`es can be passed or, as in most cases, the ad-hoc created `String` objects can be passed by value instead of by reference, resulting in less mental load on the calling side. Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
Diffstat (limited to 'crates/core/tedge')
-rw-r--r--crates/core/tedge/src/main.rs23
1 files changed, 16 insertions, 7 deletions
diff --git a/crates/core/tedge/src/main.rs b/crates/core/tedge/src/main.rs
index ea5ccd9a..4bf6b5f6 100644
--- a/crates/core/tedge/src/main.rs
+++ b/crates/core/tedge/src/main.rs
@@ -46,20 +46,29 @@ fn main() -> anyhow::Result<()> {
}
}
-fn initialize_tedge(cfg_dir: &Path) -> anyhow::Result<()> {
- let config_dir = cfg_dir.display().to_string();
- create_directory_with_user_group(&config_dir, "tedge", "tedge", 0o775)?;
+fn initialize_tedge(config_dir: &Path) -> anyhow::Result<()> {
+ create_directory_with_user_group(config_dir, "tedge", "tedge", 0o775)?;
create_directory_with_user_group("/var/log/tedge", "tedge", "tedge", 0o775)?;
create_directory_with_user_group(
- &format!("{config_dir}/mosquitto-conf"),
+ format!("{}/mosquitto-conf", config_dir.display()),
"tedge",
"tedge",
0o775,
)?;
- create_directory_with_user_group(&format!("{config_dir}/operations"), "tedge", "tedge", 0o775)?;
- create_directory_with_user_group(&format!("{config_dir}/plugins"), "tedge", "tedge", 0o775)?;
create_directory_with_user_group(
- &format!("{config_dir}/device-certs"),
+ format!("{}/operations", config_dir.display()),
+ "tedge",
+ "tedge",
+ 0o775,
+ )?;
+ create_directory_with_user_group(
+ format!("{}/plugins", config_dir.display()),
+ "tedge",
+ "tedge",
+ 0o775,
+ )?;
+ create_directory_with_user_group(
+ format!("{}/device-certs", config_dir.display()),
"mosquitto",
"mosquitto",
0o775,