From eb9b1522445aa84ff9cce8e2f1cf3e816a7f1bf7 Mon Sep 17 00:00:00 2001 From: TOwInOK <60252419+TOwInOK@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:22:08 +0700 Subject: [PATCH] Gave up the idea of dependencies. #2 Now the user decides whether to add them or not. Now it is possible to download plugins. In the future plugins will simply become dependencies with an affiliation type. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Отказался от идеи зависимостей. Теперь пользователь решает, добавлять их или нет. Теперь можно скачивать плагины. В будущем плагины просто станут зависимостями с типом принадлежности. Finalized the work for the cores. #3 Доделана работа для ядер. --- .gitignore | 3 +- config.lock | 24 ++++ config.toml | 24 ++-- src/config/plugins.rs | 12 +- src/config/versions.rs | 17 +++ src/downloader/core.rs | 112 ++++++++++++++++++ src/downloader/mod.rs | 102 +++++++++++----- src/downloader/models/cores/paper.rs | 2 +- src/downloader/models/cores/purpur.rs | 2 +- src/downloader/models/cores/vanilla.rs | 2 +- .../models/{plugins => extensions}/mod.rs | 0 src/downloader/models/extensions/modrinth.rs | 73 ++++++++++++ src/downloader/models/mod.rs | 2 +- src/downloader/models/model.rs | 22 ++-- src/downloader/models/plugins/modrinth.rs | 46 ------- src/lock/lock.rs | 24 +--- src/main.rs | 2 +- src/networkmanager/controller.rs | 14 +++ src/networkmanager/mod.rs | 0 19 files changed, 356 insertions(+), 127 deletions(-) create mode 100644 src/downloader/core.rs rename src/downloader/models/{plugins => extensions}/mod.rs (100%) create mode 100644 src/downloader/models/extensions/modrinth.rs delete mode 100644 src/downloader/models/plugins/modrinth.rs create mode 100644 src/networkmanager/controller.rs create mode 100644 src/networkmanager/mod.rs diff --git a/.gitignore b/.gitignore index 3921712..bcd542f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /core -/core/* \ No newline at end of file +/core/* +/plugins/ \ No newline at end of file diff --git a/config.lock b/config.lock index 4a429ce..760cb59 100644 --- a/config.lock +++ b/config.lock @@ -4,3 +4,27 @@ name = "Paper" version = "1.20.4" build = "462" + +[[metaData]] + +[metaData.Plugin] +name = "simple-voice-chat" +version = "latest" + +[[metaData]] + +[metaData.Plugin] +name = "chunky" +version = "latest" + +[[metaData]] + +[metaData.Plugin] +name = "terra" +version = "latest" + +[[metaData]] + +[metaData.Plugin] +name = "itemswapper" +version = "latest" diff --git a/config.toml b/config.toml index b54e93c..2575c81 100644 --- a/config.toml +++ b/config.toml @@ -8,18 +8,22 @@ force_update = false [plugins] - [plugins.simple_voice_chat2] - version = "ail5iPUK" + [plugins.simple-voice-chat] + [plugins.chunky] + [plugins.itemswapper] + [plugins.terra] channel = "beta" - freeze = false - update = false + # version = "ail5iPUK" + # channel = "beta" + # freeze = false + # update = false - [plugins.cooler2] - source = "hangar" - version = "ail5iPUK" - channel = "beta" - freeze = false - update = true + # [plugins.cooler2] + # source = "hangar" + # version = "ail5iPUK" + # channel = "beta" + # freeze = false + # update = true [additions] configPluguinsFrom = "git@github.com:TOwInOK/test.git" diff --git a/src/config/plugins.rs b/src/config/plugins.rs index 72b955c..44cc57d 100644 --- a/src/config/plugins.rs +++ b/src/config/plugins.rs @@ -35,11 +35,21 @@ pub enum Sources { #[serde(rename_all = "lowercase")] pub enum Channels { #[default] - Stable, + Release, Beta, Alpha, } +impl Channels { + pub async fn get_str(&self) -> &str { + match self { + Channels::Release => "release", + Channels::Beta => "beta", + Channels::Alpha => "alpha", + } + } +} + impl Plugin { pub async fn freeze(&self) -> bool { info!("Check freeze and force_update"); diff --git a/src/config/versions.rs b/src/config/versions.rs index 8ff74a3..3ac3302 100644 --- a/src/config/versions.rs +++ b/src/config/versions.rs @@ -1,3 +1,5 @@ +use std::ops::Deref; + use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[derive(Debug, Default, PartialEq, Clone, Eq)] pub enum Versions { @@ -6,6 +8,21 @@ pub enum Versions { Latest, } +impl Versions { + pub async fn is_latest(&self) -> bool { + match self { + Versions::Version(_) => false, + Versions::Latest => true, + } + } + pub async fn get_version(&self) -> &str { + match self { + Versions::Version(e) => e.deref(), + Versions::Latest => "latest", + } + } +} + impl<'de> Deserialize<'de> for Versions { fn deserialize(deserializer: D) -> Result where diff --git a/src/downloader/core.rs b/src/downloader/core.rs new file mode 100644 index 0000000..04e22d9 --- /dev/null +++ b/src/downloader/core.rs @@ -0,0 +1,112 @@ +use log::{debug, info}; + +use crate::config::core::{Core, Provider}; +use crate::downloader::models::cores::folia::Folia; +use crate::downloader::models::cores::paper::Paper; +use crate::downloader::models::cores::purpur::Purpur; +use crate::downloader::models::cores::vanilla::Vanilla; +use crate::downloader::models::cores::velocity::Velocity; +use crate::downloader::models::cores::waterfall::Waterfall; +use crate::downloader::models::model::ModelCore; +use crate::errors::error::DownloadErrors; +use crate::lock::lock::{ExistState, Lock, Meta, MetaData}; + +use super::hash::ChooseHash; + + +pub trait CoreDownloader { + ///Check core and add it into list for download. +async fn get_core_link(core: &mut Core) -> Result<(String, ChooseHash), DownloadErrors> { + info!("Start to match provider of core"); + match core.provider { + Provider::Vanilla => Vanilla::get_link(core).await, + Provider::Paper => Paper::get_link(core).await, + Provider::Folia => Folia::get_link(core).await, + Provider::Purpur => Purpur::get_link(core).await, + Provider::Fabric => todo!(), + Provider::Forge => todo!(), + Provider::NeoForge => todo!(), + Provider::Waterfall => Waterfall::get_link(core).await, + Provider::Velocity => Velocity::get_link(core).await, + } +} + +/// Make reqwest to check version and download core. +async fn core_reqwest(core: &mut Core, lock: &mut Lock) -> Result<(), DownloadErrors> { + //Find version to download + let (link, hash) = Self::get_core_link(core).await?; + let core_name = core.provider.get_name().await.as_str(); + debug!("Find {} link: {}, hash: {}", core_name, &link, &hash); + info!("Start to download {}!", core_name); + //Need to update or download? + match lock + .exist(&Meta::Core(MetaData { + name: core_name.to_string(), + version: core.version, + build: core.build.into(), + dependencies: None, + })) + .await + { + ExistState::Exist => { + if core.freeze().await { + return Ok(()); + } + Self::force_update(self, core_name, link, hash).await + } + ExistState::DifferentVersion | ExistState::DifferentBuild => { + if core.freeze().await { + return Ok(()); + } + info!("Core have different or build version, Download!"); + Self::download_core(core_name, link, hash).await + } + ExistState::None => { + info!("No one core find, Download!"); + Self::download_core(core_name, link, hash).await + } + } +} + +async fn force_update( + lock: &mut Lock, + core: &Core, + link: String, + hash: ChooseHash, +) -> Result<(), DownloadErrors> { + if core.force_update { + core.force_update = false; + info!("Force update core!"); + return Self::download_core(core.provider.get_name(), link, hash).await; + } + info!("Core doesn't need to download"); + Ok(()) +} +/// download core +async fn download_core( + lock: &mut Lock, + name: &str, + link: String, + hash: ChooseHash, +) -> Result<(), DownloadErrors> { + //delete all cores from meta and dir + lock + .delete_core(&self.config.additions.path_to_core).await?; + //download + get_file(link, hash, &self.config.additions.path_to_core, name).await?; + + //get meta data + let meta = Meta::Core(MetaData::new( + name.to_string(), + self.config.core.version.clone(), + self.config.core.build.clone().into(), + None, + )); + //push to lock + self.lock.add(meta).await; + //save lock + self.lock.save(&self.config.additions.path_to_lock).await?; + Ok(()) +} + +} diff --git a/src/downloader/mod.rs b/src/downloader/mod.rs index facfc26..33e3b0c 100644 --- a/src/downloader/mod.rs +++ b/src/downloader/mod.rs @@ -3,6 +3,7 @@ mod models; use crate::config::core::Provider; use crate::config::plugins::{Plugin, Sources}; +use crate::config::versions::Versions; use crate::config::Config; use crate::downloader::models::cores::folia::Folia; use crate::downloader::models::cores::paper::Paper; @@ -20,6 +21,8 @@ use std::io::Write; use std::path::Path; use self::hash::ChooseHash; +use self::models::extensions::modrinth::ModrinthData; +use self::models::model::ModelExtensions; #[derive(Debug)] pub struct Downloader<'config, 'lock> { @@ -29,29 +32,31 @@ pub struct Downloader<'config, 'lock> { impl<'config, 'lock> Downloader<'config, 'lock> { pub fn new(config: &'config mut Config, lock: &'lock mut Lock) -> Self { - Self { config, lock } + Self { config, lock} } ///Check and download plugins, mods, core - pub async fn check(&mut self) -> Result<(), DownloadErrors> { + pub async fn check_and_download(&mut self) -> Result<(), DownloadErrors> { info!("Start check fn"); - self.core_reqwest().await - // self.plugin_reqwest().await + self.core_reqwest().await?; + self.plugin_reqwest().await } + /////Core section + ///Check core and add it into list for download. async fn get_core_link(&mut self) -> Result<(String, ChooseHash), DownloadErrors> { info!("Start to match provider of core"); match &self.config.core.provider { - Provider::Vanilla => Vanilla::find(&mut self.config.core).await, - Provider::Paper => Paper::find(&mut self.config.core).await, - Provider::Folia => Folia::find(&mut self.config.core).await, - Provider::Purpur => Purpur::find(&mut self.config.core).await, + Provider::Vanilla => Vanilla::get_link(&mut self.config.core).await, + Provider::Paper => Paper::get_link(&mut self.config.core).await, + Provider::Folia => Folia::get_link(&mut self.config.core).await, + Provider::Purpur => Purpur::get_link(&mut self.config.core).await, Provider::Fabric => todo!(), Provider::Forge => todo!(), Provider::NeoForge => todo!(), - Provider::Waterfall => Waterfall::find(&mut self.config.core).await, - Provider::Velocity => Velocity::find(&mut self.config.core).await, + Provider::Waterfall => Waterfall::get_link(&mut self.config.core).await, + Provider::Velocity => Velocity::get_link(&mut self.config.core).await, } } @@ -69,7 +74,6 @@ impl<'config, 'lock> Downloader<'config, 'lock> { name: core_name.to_string(), version: self.config.core.version.clone(), build: self.config.core.build.clone().into(), - dependencies: None, })) .await { @@ -77,7 +81,7 @@ impl<'config, 'lock> Downloader<'config, 'lock> { if self.config.core.freeze().await { return Ok(()); } - Self::force_update(self, core_name, link, hash).await + Self::core_force_update(self, core_name, link, hash).await } ExistState::DifferentVersion | ExistState::DifferentBuild => { if self.config.core.freeze().await { @@ -93,7 +97,7 @@ impl<'config, 'lock> Downloader<'config, 'lock> { } } - async fn force_update( + async fn core_force_update( &mut self, core_name: &str, link: String, @@ -126,7 +130,6 @@ impl<'config, 'lock> Downloader<'config, 'lock> { name.to_string(), self.config.core.version.clone(), self.config.core.build.clone().into(), - None, )); //push to lock self.lock.add(meta).await; @@ -135,29 +138,54 @@ impl<'config, 'lock> Downloader<'config, 'lock> { Ok(()) } + ///////Plugin Section + /// Make reqwest to check version and download [`Plugin`]. async fn plugin_reqwest(&mut self) -> Result<(), DownloadErrors> { if self.config.plugins.is_empty() { return Ok(()); }; - for (name, plugin) in self.config.plugins.iter_mut() { + for (name, plugin) in self.config.plugins.iter_mut().map(|(name, plugin)| { + return (name.to_lowercase().replace("_", "-"), plugin); + }) { if plugin.freeze().await { continue; } - let (link, hash) = Self::get_plugin_link(name, plugin).await?; + let (link, hash) = Self::get_plugin_link(&name, plugin, &self.config.core.version, &self.config.core.provider.get_name().await.to_lowercase()).await?; + let plugin_meta = Meta::Plugin(MetaData { + name: name.to_string(), + version: plugin.version.clone(), + build: None, + }); // Check exist plugin. - // match self - // .lock - // .exist(&Meta::Plugin(MetaData { - // name: core_name.to_string(), - // version: self.config.core.version.clone(), - // build: self.config.core.build.clone().into(), - // dependencies: None, - // })) - // .await? {} - // - Self::download_plugin(self.lock, name, plugin).await? // use it inside + match self + .lock + .exist(&plugin_meta) + .await { + ExistState::Exist => { + if plugin.freeze().await { + return Ok(()); + } + // Download force update + if plugin.force_update { + info!("Plugin: {}. Force download!", name); + Self::download_plugin(self.lock,&self.config.additions.path_to_plugins, &self.config.additions.path_to_configs, &name, link, hash, plugin_meta).await? + } + info!("Plugin: {}. Does't need to update", name); + } + ExistState::DifferentVersion | ExistState::DifferentBuild => { + if plugin.freeze().await { + return Ok(()); + } + info!("Plugin: {}. Need tp update", name); + Self::download_plugin(self.lock,&self.config.additions.path_to_plugins, &self.config.additions.path_to_configs, &name, link, hash, plugin_meta).await? + } + ExistState::None => { + info!("No one plugin: {} find, Download!", name); + Self::download_plugin(self.lock,&self.config.additions.path_to_plugins, &self.config.additions.path_to_configs, &name, link, hash, plugin_meta).await? + } + } } Ok(()) } @@ -165,21 +193,35 @@ impl<'config, 'lock> Downloader<'config, 'lock> { /// download plugin async fn download_plugin( lock: &mut Lock, + path_plugin: &str, + path_lock: &str, name: &str, - plugin: &Plugin, + link: String, + hash: ChooseHash, + meta: Meta, ) -> Result<(), DownloadErrors> { - todo!() + //Delete plugin + lock.delete_plugin(name, path_plugin).await?; + //download plugin + get_file(link, hash, path_plugin, name).await?; + //push to lock + lock.add(meta).await; + //save lock + lock.save(path_lock).await?; + Ok(()) } ///Check plugins and add it into list for download. async fn get_plugin_link( name: &str, plugin: &Plugin, + game_version: &Versions, + loader: &str, ) -> Result<(String, ChooseHash), DownloadErrors> { match plugin.source { Sources::Spigot => todo!(), Sources::Hangar => todo!(), - Sources::Modrinth => todo!(), + Sources::Modrinth => ModrinthData::get_link(name, plugin, game_version, loader).await, Sources::CurseForge => todo!(), } } diff --git a/src/downloader/models/cores/paper.rs b/src/downloader/models/cores/paper.rs index 1b9460e..fcebbf6 100644 --- a/src/downloader/models/cores/paper.rs +++ b/src/downloader/models/cores/paper.rs @@ -44,7 +44,7 @@ pub struct Application { impl ModelCore for T { //find build and push link - async fn find(core: &mut Core) -> Result<(String, ChooseHash), DownloadErrors> { + async fn get_link(core: &mut Core) -> Result<(String, ChooseHash), DownloadErrors> { let core_name = Self::CORE_NAME; let build = &mut core.build; let version = &core.version; diff --git a/src/downloader/models/cores/purpur.rs b/src/downloader/models/cores/purpur.rs index deee44b..12fe3f1 100644 --- a/src/downloader/models/cores/purpur.rs +++ b/src/downloader/models/cores/purpur.rs @@ -37,7 +37,7 @@ pub struct FileHash { impl ModelCore for Purpur { //find build and push link - async fn find(core: &mut Core) -> Result<(String, ChooseHash), DownloadErrors> { + async fn get_link(core: &mut Core) -> Result<(String, ChooseHash), DownloadErrors> { let version = &core.version; let version = Self::find_version(version).await?; let build = &mut core.build; diff --git a/src/downloader/models/cores/vanilla.rs b/src/downloader/models/cores/vanilla.rs index 8a02a0d..29bc862 100644 --- a/src/downloader/models/cores/vanilla.rs +++ b/src/downloader/models/cores/vanilla.rs @@ -81,7 +81,7 @@ pub struct Server { impl ModelCore for Vanilla { /// Making request to mojang api and find the link to download minecraft.jar - async fn find(core: &mut Core) -> Result<(OuterLink, ChooseHash), DownloadErrors> { + async fn get_link(core: &mut Core) -> Result<(OuterLink, ChooseHash), DownloadErrors> { let version = &core.version; info!("Start find fn with version: {:#?}", version); let link = Self::find_version(version).await?; diff --git a/src/downloader/models/plugins/mod.rs b/src/downloader/models/extensions/mod.rs similarity index 100% rename from src/downloader/models/plugins/mod.rs rename to src/downloader/models/extensions/mod.rs diff --git a/src/downloader/models/extensions/modrinth.rs b/src/downloader/models/extensions/modrinth.rs new file mode 100644 index 0000000..02a1b03 --- /dev/null +++ b/src/downloader/models/extensions/modrinth.rs @@ -0,0 +1,73 @@ +use log::info; +use serde::Deserialize; +use serde::Serialize; + +use crate::downloader::hash::ChooseHash; +use crate::downloader::models::model::ModelExtensions; +use crate::errors::error::DownloadErrors; + +///# Example +///we have cdn like this: `https://cdn.modrinth.com/data/PROJECT_ID/versions/ID/NAME-LOADER-VERSION.jar` +///we can take `[project_id]` -> `AANobbMI` +///we can take `[id]` -> `4GyXKCLd` +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct ModrinthData { + //Always change ich version + pub id: String, + //Stable token. + pub project_id: String, + pub files: Vec, + pub dependencies: Vec, +} + +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct File { + pub hashes: Hashes, + pub url: String, +} + +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct Hashes { + pub sha1: String, + pub sha512: String, +} + +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct Dependency { + pub project_id: String, + pub dependency_type: String, +} + +impl ModelExtensions for ModrinthData { + async fn get_link( + name: &str, + plugin: &crate::config::plugins::Plugin, + game_version: &crate::config::versions::Versions, + loader: &str, + ) -> Result<(String, crate::downloader::hash::ChooseHash), crate::errors::error::DownloadErrors> + { + let link: String = { + match game_version { + crate::config::versions::Versions::Version(game_version) => { + let channel = plugin.channel.get_str().await; + let link = format!("https://api.modrinth.com/v2/project/{}/version?game_versions=[\"{}\"]&loaders=[\"{}\"]&featured=true&version_type={}", name, game_version, loader, channel); + info!("Modrinth link: {}", &link); + link + } + crate::config::versions::Versions::Latest => { + let channel = plugin.channel.get_str().await; + let link = format!("https://api.modrinth.com/v2/project/{}/version?&loaders=[\"{}\"]&featured=true&version_type={}", name, loader, channel); + info!("Modrinth link: {}", &link); + link + } + } + }; + let modrinth_data: Vec = reqwest::get(link).await?.json().await?; + let modrinth_data = match modrinth_data.first() { + Some(e) => Ok(e), + None => Err(DownloadErrors::DownloadCorrupt(format!("No one plugin: {}, has found.", name.to_string()))), + }?; + Ok(modrinth_data.files.first().map(|x| (x.url.to_string(), ChooseHash::SHA1(x.hashes.sha1.to_string()))).unwrap()) + } +} + diff --git a/src/downloader/models/mod.rs b/src/downloader/models/mod.rs index d4a2326..0562acf 100644 --- a/src/downloader/models/mod.rs +++ b/src/downloader/models/mod.rs @@ -1,3 +1,3 @@ pub mod cores; +pub mod extensions; pub mod model; -pub mod plugins; diff --git a/src/downloader/models/model.rs b/src/downloader/models/model.rs index 6d534ec..bbe65e6 100644 --- a/src/downloader/models/model.rs +++ b/src/downloader/models/model.rs @@ -1,22 +1,20 @@ use crate::{ - config::{core::Core, versions::Versions}, + config::{core::Core, plugins::Plugin, versions::Versions}, downloader::hash::ChooseHash, errors::error::{ConfigErrors, DownloadErrors}, - lock::lock::Lock, }; -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; pub trait ModelCore { - async fn find(core: &mut Core) -> Result<(String, ChooseHash), DownloadErrors>; + async fn get_link(core: &mut Core) -> Result<(String, ChooseHash), DownloadErrors>; async fn find_version(version: &Versions) -> Result; } -pub trait ModelPlugins { - async fn find(version: &Versions, build: &str) -> Result<(String, ChooseHash), ConfigErrors>; - async fn find_version(version: &Versions) -> Result; - async fn make_download_list( - lock: &Lock, - deps: Vec, - version: &Versions, - ) -> HashSet<(String, ChooseHash)>; +pub trait ModelExtensions { + async fn get_link( + name: &str, + plugin: &Plugin, + game_version: &Versions, + loader: &str, + ) -> Result<(String, ChooseHash), DownloadErrors>; } diff --git a/src/downloader/models/plugins/modrinth.rs b/src/downloader/models/plugins/modrinth.rs deleted file mode 100644 index 364d010..0000000 --- a/src/downloader/models/plugins/modrinth.rs +++ /dev/null @@ -1,46 +0,0 @@ -use serde::Deserialize; -use serde::Serialize; -use serde_json::Value; - -type ProjectID = String; -type PluginID = String; - -///# Example -///we have cdn like this: `https://cdn.modrinth.com/data/PROJECT_ID/versions/ID/NAME-LOADER-VERSION.jar` -///we can take `[project_id]` -> `AANobbMI` -///we can take `[id]` -> `4GyXKCLd` -#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct ModrinthData { - //Always change ich version - pub id: PluginID, - //Stable token. - pub project_id: ProjectID, - pub files: Vec, - pub dependencies: Vec, -} - -#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct File { - pub hashes: Hashes, - pub url: String, -} - -#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct Hashes { - pub sha1: String, - // pub sha512: String, -} - -#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct Dependency { - #[serde(rename = "version_id")] - pub version_id: Value, - #[serde(rename = "file_name")] - pub file_name: Value, - #[serde(rename = "dependency_type")] - pub dependency_type: String, -} diff --git a/src/lock/lock.rs b/src/lock/lock.rs index 475fe50..9e349fd 100644 --- a/src/lock/lock.rs +++ b/src/lock/lock.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use log::{debug, error, info}; +use log::{debug, info}; use serde::{Deserialize, Serialize}; use crate::{ @@ -156,7 +156,6 @@ impl Lock { self.meta_data.iter().find(|m| { m.get_name() == outer_meta.get_name() && m.get_version() == outer_meta.get_version() - && m.get_dependencies() != outer_meta.get_dependencies() }) } @@ -183,7 +182,7 @@ impl Lock { ///Delete plugin pub async fn delete_plugin( &mut self, - name: String, + name: &str, download_dir: &str, ) -> Result<(), LockErrors> { match self @@ -287,16 +286,6 @@ impl Meta { Meta::Core(e) | Meta::Plugin(e) | Meta::Mod(e) => e.set_build(build), } } - pub fn get_dependencies(&self) -> Option<&Vec> { - match self { - Meta::Core(e) | Meta::Plugin(e) | Meta::Mod(e) => e.get_dependencies(), - } - } - pub fn set_dependencies(&mut self, deps: Option>) { - match self { - Meta::Core(e) | Meta::Plugin(e) | Meta::Mod(e) => e.set_dependencies(deps), - } - } } #[derive(Debug, PartialEq, Serialize, Deserialize, Eq)] @@ -304,7 +293,6 @@ pub struct MetaData { pub name: String, pub version: Versions, pub build: Option, - pub dependencies: Option>, } impl MetaData { @@ -312,13 +300,11 @@ impl MetaData { name: String, version: Versions, build: Option, - dependencies: Option>, ) -> Self { Self { name, version, build, - dependencies, } } @@ -345,10 +331,4 @@ impl MetaData { pub fn set_build(&mut self, build: Option) { self.build = build; } - pub fn get_dependencies(&self) -> Option<&Vec> { - self.dependencies.as_ref() - } - pub fn set_dependencies(&mut self, deps: Option>) { - self.dependencies = deps; - } } diff --git a/src/main.rs b/src/main.rs index c263641..5cb2f67 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,7 +45,7 @@ async fn main() { loop { interval.tick().await; Downloader::new(&mut config, &mut lock) - .check() + .check_and_download() .await .unwrap_or_else(|e| error!("{e}")); } diff --git a/src/networkmanager/controller.rs b/src/networkmanager/controller.rs new file mode 100644 index 0000000..0d9cb08 --- /dev/null +++ b/src/networkmanager/controller.rs @@ -0,0 +1,14 @@ +//config/lock/show - show lock [get] +///// +//config/core/change - change mod. Push MetaData +//config/extension/change?name="" - change extension. Push MetaData +///// +//config/change - push config and change it. [put] +///// +//config/core/check - check core +//config/extension/check?name="" - check extension +///// +//config/check - check all +//config/show - push all configuration +///// +//config/extension/delete?name="" - delete any plugin, mod. \ No newline at end of file diff --git a/src/networkmanager/mod.rs b/src/networkmanager/mod.rs new file mode 100644 index 0000000..e69de29