Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
fixed #11
Browse files Browse the repository at this point in the history
Make the hash vector much smaller
fixed #10
Implemented dictionary for pb (Progress bar) #7
Edit ReadMe
Add many tracies (debug, trace, info)
change some errors
make 'de toml erros more pretty
  • Loading branch information
TOwInOK committed May 25, 2024
1 parent 1be4f3c commit 7490d12
Show file tree
Hide file tree
Showing 30 changed files with 759 additions and 376 deletions.
Binary file added .DS_Store
Binary file not shown.
153 changes: 85 additions & 68 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
async-trait = "0.1.80"
async-watcher = "0.2.1"
bytes = "1.6.0"
console = "0.15.8"
futures-util = "0.3.30"
indicatif = { version = "0.17.8", features = ["tokio"] }
indicatif-log-bridge = "0.2.2"
lazy_static = "1.4.0"
log = "0.4.21"
md-5 = "0.10.6"
pretty_env_logger = "0.5.0"
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

# Что реализуется

- [x] Обновление, загрузка плагинов.
- [x] Обновление, загрузка ядра.
- [x] Обновление, загрузка плагинов
- [x] Обновление, загрузка ядра
- [x] Чтение конфигурационных файлов
- [x] Загрузка языкового файла
- [ ] Запуск minecraft
- [ ] Бекапы
- [ ] Загрузка конфигурационных файлов через git
Expand All @@ -41,9 +42,10 @@

# What is implemented

- [x] Update, load plugins.
- [x] Updating, loading kernels.
- [x] Update, load plugins
- [x] Updating, loading kernels
- [x] Reading configuration files
- [x] Load language file
- [ ] Running minecraft
- [ ] Backups
- [ ] Uploading configuration files via git
Expand All @@ -67,7 +69,7 @@ There is a start, but we need to realize the loading of cores.

## Mods

- Modrinth
- Modrinth (soon)
- CurseForge (not implemented)

## Cores
Expand Down
22 changes: 22 additions & 0 deletions language.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
calculate_hash = "Calculate hash..."
delete_exist_version = "Delete exist version!"
doest_need_to_update = "Does't need to update!"
done = "Done!"
download_file = "Download file..."
file_downloaded = "File downloaded!"
restart = "Restart..."
saving_file = "Saving file..."
start_new_iteration = "Start new iteration!"
stop_iteration = "Stop iteration!"
waiting_new_iteration = "Waiting new iteration..."
write_to_lock = "Write to lock!"
find_changes_in_settings = "Find some changes in settings!"
settings_changed = "Settings changed"
settings_has_rewrited = "Settings has rewrited"
settings_same = "Settings same"
intro = "MAC ready to work!"
init_work = "Generating link..."
finding_version = "Finding version..."
make_link = "Make link..."
start_remove_nonexist = "Start remove nonexist"
remove_nonexist = "Remove nonexist"
22 changes: 22 additions & 0 deletions language_ru-example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
calculate_hash = "Вычисление хеша..."
delete_exist_version = "Удаление существующей версии!"
doest_need_to_update = "Не требует обновления!"
done = "Готово!"
download_file = "Загрузка файла..."
file_downloaded = "Файл загружен!"
restart = "Перезапуск..."
saving_file = "Сохранение файла..."
start_new_iteration = "Начало новой итерации!"
stop_iteration = "Остановка итерации!"
waiting_new_iteration = "Ожидание новой итерации..."
write_to_lock = "Логирование файла!"
find_changes_in_settings = "Найдены изменения в настройках!"
settings_changed = "Настройки изменены"
settings_has_rewrited = "Настройки перезаписаны"
settings_same = "Настройки те же"
intro = "МАК готов к работе!"
init_work = "Генерация ссылки..."
finding_version = "Поиск версии..."
make_link = "Создание ссылки..."
start_remove_nonexist = "Удаление не логируемых файлов"
remove_nonexist = "Удаление не существующего:"
6 changes: 3 additions & 3 deletions settings.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[core]
provider = "paper"
version = "1.20.6"
version = "1.20.4"

[plugins]
[plugins.simple-voice-chat]
[plugins.chunky]
[plugins.nbtapi]
[plugins.chunkyborder]
[plugins.discordsrv]
28 changes: 14 additions & 14 deletions settings_example.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Require
[core] # just core, nothing here to change :)
provider = "paper" # [vanilla, paper, folia, purpur, fabric, waterfall, velocity]
version = "1.20.6" # Or Latest (latest -> get error)
provider = "paper" # [vanilla, paper, folia, purpur, fabric, waterfall, velocity]
version = "1.20.6" # Or Latest (latest -> get error)
force_update = true

# Optional
[plugins.name] # name be used only in kebab-case
source = "modrinth" # [hangar, modrinth] => modrinth by default
version = "ffdfdsd" # numbers of this version.
channel = "release" # [release, beta, alpha] => release
freeze = false # false || true => false by default
source = "modrinth" # [hangar, modrinth] => modrinth by default
version = "ffdfdsd" # numbers of this version.
channel = "release" # [release, beta, alpha] => release
freeze = false # false || true => false by default
force_update = false # false || true => false by default

# Optional
[mods.name] # name be used only in kebab-case
source = "modrinth" # [hangar, modrinth] => modrinth by default
version = "ffdfdsd" # numbers of this version.
channel = "release" # [release, beta, alpha] => release
freeze = false # false || true => false by default
[mods.name] # name be used only in kebab-case ^Not implemented!!!
source = "modrinth" # [hangar, modrinth] => modrinth by default
version = "ffdfdsd" # numbers of this version.
channel = "release" # [release, beta, alpha] => release
freeze = false # false || true => false by default
force_update = false # false || true => false by default

# Optional
[additions]
source = "[email protected]:Username/Super-Config.git" # Optional, require for key
key = "MySuperMegaKey" # Optional, don't work without link
duraction = 300 # Optional, value of duraction between manager checker iterations (in seconds)
source = "[email protected]:Username/Super-Config.git" # Optional, require for key ^Not implemented!!!
key = "MySuperMegaKey" # Optional, don't work without link ^Not implemented!!!
duraction = 300 # Optional, value of duraction between manager check iterations (in seconds) => 300 by default
1 change: 1 addition & 0 deletions src/dictionary/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod pb_messages;
71 changes: 71 additions & 0 deletions src/dictionary/pb_messages.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
use serde::{Deserialize, Serialize};

use crate::tr::load::Load;

#[derive(Deserialize, Serialize)]
pub struct PbMessages {
pub calculate_hash: String,
pub delete_exist_version: String,
pub doest_need_to_update: String,
pub done: String,
pub download_file: String,
pub file_downloaded: String,
pub restart: String,
pub saving_file: String,
pub start_new_iteration: String,
pub stop_iteration: String,
pub waiting_new_iteration: String,
pub write_to_lock: String,
// Config
pub find_changes_in_settings: String,
pub settings_changed: String,
pub settings_has_rewrited: String,
pub settings_same: String,
// Intro
pub intro: String,
// Models messages
pub init_work: String,
pub finding_version: String,
pub make_link: String,
// Remove nonexist
pub start_remove_nonexist: String,
pub remove_nonexist: String,
}

impl Default for PbMessages {
fn default() -> Self {
Self {
restart: "Restart...".into(),
stop_iteration: "Stop iteration!".into(),
start_new_iteration: "Start new iteration!".into(),
waiting_new_iteration: "Waiting new iteration...".into(),
doest_need_to_update: "Does't need to update!".into(),
delete_exist_version: "Delete exist version!".into(),
download_file: "Download file...".into(),
saving_file: "Saving file...".into(),
write_to_lock: "Write to lock!".into(),
done: "Done!".into(),
file_downloaded: "File downloaded!".into(),
calculate_hash: "Calculate hash...".into(),
find_changes_in_settings: "Find some changes in settings!".into(),
settings_changed: "Settings changed".into(),
settings_has_rewrited: "Settings has rewrited".into(),
settings_same: "Settings same".into(),
intro: "MAC ready to work!".into(),
init_work: "Generating link...".into(),
finding_version: "Finding version...".into(),
make_link: "Make link...".into(),
start_remove_nonexist: "Start remove nonexist".into(),
remove_nonexist: "Remove nonexist".into(),
}
}
}
impl PbMessages {
pub fn remove_if_nonexist(&self, name: &str) -> String {
format!("{}: {}", self.remove_nonexist, name)
}
}

impl Load for PbMessages {
const PATH: &'static str = "language.toml";
}
50 changes: 26 additions & 24 deletions src/errors/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use crate::mananger::messages::Messages;

#[derive(Error, Debug)]
pub enum CompareHashError {
#[error("Хэш не совпадает")]
HashNotCompare(),
#[error("Хэш не совпадает: expect => {0}, value => {1}")]
HashNotCompare(String, String),
#[error("Конвертация Sha1 проведена не успешно : {0}")]
SHA1(std::io::Error),
#[error("Конвертация Sha256 проведена не успешно : {0}")]
Expand All @@ -18,22 +18,20 @@ pub enum CompareHashError {

#[derive(Error, Debug)]
pub enum Error {
#[error("Проблема с обработкой запроса: {0}")]
#[error("Reqwest error: {0}")]
Reqwest(#[from] reqwest::Error),
#[error("Проблема с обработкой хэша: {0}")]
#[error("Hash corrupted: {0}")]
CompareHash(CompareHashError),
// #[error("Проблема с скачиванием файла: {0}")]
// Download(String),
#[error("Ошибка ввода/вывода: {0}")]
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("{0}")]
#[error("TOML parse error{0}")]
TomlParse(String),
#[error("Ошибка сериализация TOML: {0}")]
#[error("Serialization of TOML error: {0}")]
TomlSerialize(#[from] toml::ser::Error),
#[error("Не удалось найти: {0}")]
#[error("Not found: {0}")]
NotFound(String),
#[error("Ошибка: {0}")]
Any(#[from] Box<dyn std::error::Error + Send>),
// #[error("Any error: {0}")]
// Any(#[from] Box<dyn std::error::Error + Send>),
#[error("Task join error: {0}")]
JoinError(#[from] tokio::task::JoinError),
#[error("Indicatif template error: {0}")]
Expand All @@ -48,18 +46,20 @@ impl From<toml::de::Error> for Error {
let value = value.to_string();
let parts: Vec<&str> = value.split('|').collect();

// Проверяем, что индексы существуют и выбираем только нужные
let message = if parts.len() >= 4 {
let third_part = parts[3].trim();
let trimmed_third_part = &third_part[2..]; // Удаляем первые три символа
let third_part: String = parts[3]
.trim()
.chars()
.filter(|x| *x != '^' || *x != '\\')
.collect();
format!(
" Where => {} ||| What => {} ||| why => {} ",
parts[0].trim(),
parts[2].trim(),
trimmed_third_part
third_part
)
} else {
value.to_string() // Если не удалось разделить на нужное количество частей, вернем исходную строку
value.to_string()
};

Error::TomlParse(message)
Expand All @@ -83,13 +83,6 @@ macro_rules! not_found_path {
};
}

// #[macro_export]
// macro_rules! download_error {
// ($($arg:tt)*) => {
// Err(Error::Download(format!($($arg)*)))
// };
// }

#[macro_export]
macro_rules! not_found_build_error {
($arg:tt) => {
Expand All @@ -116,3 +109,12 @@ macro_rules! not_found_plugin_error {
)))
};
}
#[macro_export]
macro_rules! not_found_plugin_link_error {
($arg:tt) => {
Err(Error::NotFound(format!(
"Not found link in for plugin: ->{}<-",
$arg
)))
};
}
3 changes: 2 additions & 1 deletion src/lock/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pub struct ExtensionMeta {
path: String,
}
impl ExtensionMeta {
pub fn new(build: String, path: String) -> Self {
pub fn new(build: String, path: &str, name: &str) -> Self {
let path = format!("{}{}.jar", path, name);
Self { build, path }
}

Expand Down
Loading

0 comments on commit 7490d12

Please sign in to comment.