Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 009e2a4

Browse files
committed
Fix bug with download plugins via config with special version
1 parent fd946c5 commit 009e2a4

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

settings.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
[core]
22
provider = "paper"
3-
version = "1.20.6"
3+
version = "1.20.1"
44

55
[plugins]
66
[plugins.simple-voice-chat]
77
[plugins.chunky]
88
[plugins.discordsrv]
9+
10+
[additions]
11+
# log_level = ""

src/errors/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ macro_rules! not_found_build_error {
9898
macro_rules! not_found_version_error {
9999
($arg:tt) => {
100100
Err(Error::NotFound(format!(
101-
"No one version ->{:#?}<- find",
101+
"No one version ->{:?}<- find",
102102
$arg
103103
)))
104104
};

src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use settings::Settings;
1919
use tokio::sync::{Mutex, RwLock};
2020

2121
static DICTIONARY: Lazy<MessageDictionary> = Lazy::new(|| MessageDictionary::get_dict().unwrap());
22-
2322
static MPB: Lazy<Arc<MultiProgress>> = Lazy::new(|| Arc::new(MultiProgress::new()));
24-
2523
static SETTINGS: Lazy<Arc<RwLock<Settings>>> = Lazy::new(|| load_settings().unwrap());
2624
static LOCK: Lazy<Arc<Mutex<Lock>>> = Lazy::new(|| load_lock().unwrap());
2725

src/manager/download.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ pub async fn download(key: Arc<CancellationToken>) -> Result<()> {
2222
'_core_scope: {
2323
tokio::spawn(async move {
2424
let settings = SETTINGS.read().await;
25-
settings.core().download().await
25+
settings.core().download().await.map_err(|e| {
26+
error!("Core scope error {:#?}", &e);
27+
e
28+
})
2629
});
2730
}
2831
'_plugins_scope: {

src/manager/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use tr::load::Load;
2727

2828
pub async fn run() -> Result<()> {
2929
let logger = pretty_env_logger::formatted_builder()
30-
.filter_level(log::LevelFilter::Info)
30+
.filter_level(log::LevelFilter::Debug)
3131
.build();
3232

3333
'_plugin_folder_scope: {

src/settings/extensions/plugin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ impl Plugin {
3333
&self.source
3434
}
3535

36-
pub fn version(&self) -> Option<&String> {
37-
self.version.as_ref()
36+
pub fn version(&self) -> Option<&str> {
37+
self.version.as_deref()
3838
}
3939

4040
pub fn channel(&self) -> &Channels {

src/settings/extensions/plugins.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,25 @@ impl Plugins {
4848
debug!("check meta: {}", &name);
4949
// Check meta
5050
if let Some(plugin_meta) = LOCK.lock().await.plugins().get(name) {
51-
let local_build = plugin_meta.build();
52-
// Need to download?
53-
if *local_build == build && !plugin.force_update() || plugin.freeze() {
54-
debug!("Does't need to update: {}", &name);
51+
let lock_build = plugin_meta.build();
52+
if let Some(version) = plugin.version() {
53+
if version != build || version != lock_build {
54+
debug!(
55+
"{} version in config -> {}, in lock {}, in api {}",
56+
name, version, lock_build, build
57+
);
58+
link_list.push((link, hash, version.to_owned(), name.to_owned(), pb));
59+
continue;
60+
}
61+
} else if lock_build == build && (!plugin.force_update() || plugin.freeze()) {
62+
debug!(
63+
"Does't need to update: {} | {} = {}",
64+
&name, &lock_build, &build
65+
);
5566
pb.set_message(DICTIONARY.downloader().doest_need_to_update());
5667
pb.finish_and_clear();
5768
continue;
69+
// Need to download?
5870
}
5971
}
6072
debug!("add link to list: {}", &name);

0 commit comments

Comments
 (0)