summaryrefslogtreecommitdiffstats
path: root/crates/core/plugin_sm/src/plugin.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/core/plugin_sm/src/plugin.rs')
-rw-r--r--crates/core/plugin_sm/src/plugin.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/crates/core/plugin_sm/src/plugin.rs b/crates/core/plugin_sm/src/plugin.rs
index c4f45ebc..eafea473 100644
--- a/crates/core/plugin_sm/src/plugin.rs
+++ b/crates/core/plugin_sm/src/plugin.rs
@@ -4,6 +4,7 @@ use async_trait::async_trait;
use csv::ReaderBuilder;
use download::Downloader;
use serde::Deserialize;
+use std::path::Path;
use std::{path::PathBuf, process::Output};
use tokio::io::BufWriter;
use tokio::{fs::File, io::AsyncWriteExt};
@@ -48,12 +49,16 @@ pub trait Plugin {
&self,
update: &SoftwareModuleUpdate,
logger: &mut BufWriter<File>,
+ download_path: &Path,
) -> Result<(), SoftwareError> {
match update.clone() {
SoftwareModuleUpdate::Install { mut module } => {
let module_url = module.url.clone();
match module_url {
- Some(url) => self.install_from_url(&mut module, &url, logger).await?,
+ Some(url) => {
+ self.install_from_url(&mut module, &url, logger, &download_path)
+ .await?
+ }
None => self.install(&module, logger).await?,
}
@@ -67,6 +72,7 @@ pub trait Plugin {
&self,
mut updates: Vec<SoftwareModuleUpdate>,
logger: &mut BufWriter<File>,
+ download_path: &Path,
) -> Vec<SoftwareError> {
let mut failed_updates = Vec::new();
@@ -85,7 +91,7 @@ pub trait Plugin {
};
let module_url = module.url.clone();
if let Some(url) = module_url {
- match Self::download_from_url(module, &url, logger).await {
+ match Self::download_from_url(module, &url, logger, &download_path).await {
Err(prepare_error) => {
failed_updates.push(prepare_error);
break;
@@ -100,7 +106,7 @@ pub trait Plugin {
let outcome = self.update_list(&updates, logger).await;
if let Err(SoftwareError::UpdateListNotSupported(_)) = outcome {
for update in updates.iter() {
- if let Err(error) = self.apply(update, logger).await {
+ if let Err(error) = self.apply(update, logger, download_path).await {
failed_updates.push(error);
};
}
@@ -130,8 +136,9 @@ pub trait Plugin {
module: &mut SoftwareModule,
url: &DownloadInfo,
logger: &mut BufWriter<File>,
+ download_path: &Path,
) -> Result<(), SoftwareError> {
- let downloader = Self::download_from_url(module, url, logger).await?;
+ let downloader = Self::download_from_url(module, url, logger, download_path).await?;
let result = self.install(module, logger).await;
Self::cleanup_downloaded_artefacts(downloader, logger).await?;
@@ -142,8 +149,9 @@ pub trait Plugin {
module: &mut SoftwareModule,
url: &DownloadInfo,
logger: &mut BufWriter<File>,
+ download_path: &Path,
) -> Result<Downloader, SoftwareError> {
- let downloader = Downloader::new(&module.name, &module.version, "/tmp");
+ let downloader = Downloader::new(&module.name, &module.version, &download_path);
logger
.write_all(