mirror of
https://github.com/mbround18/valheim-docker.git
synced 2021-10-22 21:53:54 +03:00
Fix ValheimPlus type (#451)
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -555,9 +555,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http"
|
name = "http"
|
||||||
version = "0.2.4"
|
version = "0.2.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11"
|
checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"fnv",
|
"fnv",
|
||||||
@@ -1506,9 +1506,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.11.0"
|
version = "1.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4efe6fc2395938c8155973d7be49fe8d03a843726e285e100a8a383cc0154ce"
|
checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
|||||||
@@ -203,10 +203,6 @@ If you would like to have release notifications tied into your Discord server, c
|
|||||||
**Note**: The discord is PURELY for release notifications and any + all permissions involving sending chat messages has been disabled.
|
**Note**: The discord is PURELY for release notifications and any + all permissions involving sending chat messages has been disabled.
|
||||||
[Any support for this repository must take place on the Discussions.](https://github.com/mbround18/valheim-docker/discussions)
|
[Any support for this repository must take place on the Discussions.](https://github.com/mbround18/valheim-docker/discussions)
|
||||||
|
|
||||||
# Contributions
|
|
||||||
|
|
||||||
- @some_guy - design, doc
|
|
||||||
|
|
||||||
## Versions
|
## Versions
|
||||||
|
|
||||||
- latest (Stable): Mod support! and cleaned up the code base.
|
- latest (Stable): Mod support! and cleaned up the code base.
|
||||||
|
|||||||
1425
THIRDPARTY.yml
Normal file
1425
THIRDPARTY.yml
Normal file
File diff suppressed because one or more lines are too long
@@ -14,7 +14,6 @@ use std::io::prelude::*;
|
|||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use zip::{
|
use zip::{
|
||||||
read::ZipFile,
|
|
||||||
result::{ZipError, ZipResult},
|
result::{ZipError, ZipResult},
|
||||||
ZipArchive,
|
ZipArchive,
|
||||||
};
|
};
|
||||||
@@ -102,23 +101,23 @@ impl ValheimMod {
|
|||||||
fn try_parse_manifest(&self, archive: &mut ZipArchive<File>) -> Result<Manifest, ZipError> {
|
fn try_parse_manifest(&self, archive: &mut ZipArchive<File>) -> Result<Manifest, ZipError> {
|
||||||
debug!("Parsing 'manifest.json' ...");
|
debug!("Parsing 'manifest.json' ...");
|
||||||
|
|
||||||
let mut manifest: ZipFile = match archive.by_name("manifest.json") {
|
match archive.by_name("manifest.json") {
|
||||||
Ok(value) => value,
|
Ok(mut manifest) => {
|
||||||
|
debug!("'manifest.json' successfully loaded");
|
||||||
|
let mut json_data = String::new();
|
||||||
|
manifest.read_to_string(&mut json_data).unwrap();
|
||||||
|
|
||||||
|
// Some manifest files include a UTF-8 BOM sequence, breaking serde json parsing
|
||||||
|
// See https://github.com/serde-rs/serde/issues/1753
|
||||||
|
json_data = self.remove_byte_order_mark(json_data);
|
||||||
|
|
||||||
|
Ok(serde_json::from_str(&json_data).expect("Failed to deserialize manifest file."))
|
||||||
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
error!("Failed to deserialize manifest file: {:?}", error);
|
error!("Failed to deserialize manifest file: {:?}", error);
|
||||||
// TODO: Remove Exit Code and provide an Ok or Err.
|
Err(error)
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
let mut json_data = String::new();
|
|
||||||
manifest.read_to_string(&mut json_data).unwrap();
|
|
||||||
|
|
||||||
// Some manifest files include a UTF-8 BOM sequence, breaking serde json parsing
|
|
||||||
// See https://github.com/serde-rs/serde/issues/1753
|
|
||||||
json_data = self.remove_byte_order_mark(json_data);
|
|
||||||
|
|
||||||
Ok(serde_json::from_str(&json_data).expect("Failed to deserialize manifest file."))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_byte_order_mark(&self, value: String) -> String {
|
fn remove_byte_order_mark(&self, value: String) -> String {
|
||||||
@@ -155,21 +154,20 @@ impl ValheimMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_mod_framework(&self, archive: &mut ZipArchive<File>) -> bool {
|
fn is_mod_framework(&self, archive: &mut ZipArchive<File>) -> bool {
|
||||||
let maybe_manifest = self.try_parse_manifest(archive).ok();
|
if let Ok(maybe_manifest) = self.try_parse_manifest(archive) {
|
||||||
match maybe_manifest {
|
let name = maybe_manifest.name;
|
||||||
Some(Manifest { name }) => {
|
let mod_dir = format!("{}/", name);
|
||||||
let mod_dir = format!("{}/", name);
|
let mod_dir_exists = archive.file_names().any(|file_name| file_name == mod_dir);
|
||||||
let mod_dir_exists = archive.file_names().any(|file_name| file_name == mod_dir);
|
|
||||||
|
|
||||||
// It's a mod framework based on a specific name and if it has a matching directory in the
|
// It's a mod framework based on a specific name and if it has a matching directory in the
|
||||||
// archive
|
// archive
|
||||||
debug!("Validating if file is a framework");
|
debug!("Validating if file is a framework");
|
||||||
mod_dir_exists && (name == "BepInExPack_Valheim" || name == "BepInEx_Valheim_Full")
|
mod_dir_exists && (name == "BepInExPack_Valheim" || name == "BepInEx_Valheim_Full")
|
||||||
}
|
} else {
|
||||||
None => archive
|
archive
|
||||||
// If there is no manifest, fall back to checking for winhttp.dll as a heuristic
|
// If there is no manifest, fall back to checking for winhttp.dll as a heuristic
|
||||||
.file_names()
|
.file_names()
|
||||||
.any(|file_name| file_name.eq_ignore_ascii_case("winhttp.dll")),
|
.any(|file_name| file_name.eq_ignore_ascii_case("winhttp.dll"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user