mirror of https://github.com/Tim-Paik/neutauri.git
try using anyhow
This commit is contained in:
parent
bb15d55214
commit
1f927cc6ab
|
@ -1171,6 +1171,7 @@ checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121"
|
||||||
name = "neutauri_bundler"
|
name = "neutauri_bundler"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"bincode",
|
"bincode",
|
||||||
"brotli",
|
"brotli",
|
||||||
"gumdrop",
|
"gumdrop",
|
||||||
|
|
|
@ -4,6 +4,7 @@ name = "neutauri_bundler"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = "1.0"
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
brotli = "3.3"
|
brotli = "3.3"
|
||||||
gumdrop = "0.8"
|
gumdrop = "0.8"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::data;
|
use crate::data;
|
||||||
|
use anyhow::Context;
|
||||||
use std::{
|
use std::{
|
||||||
env, fs,
|
env, fs,
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
@ -18,12 +19,12 @@ fn options() -> fs::OpenOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
fn get_runtime_data() -> io::Result<Vec<u8>> {
|
fn get_runtime_data() -> anyhow::Result<Vec<u8>> {
|
||||||
Ok(include_bytes!("../../target/release/neutauri_runtime").to_vec())
|
Ok(include_bytes!("../../target/release/neutauri_runtime").to_vec())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn get_runtime_data() -> io::Result<Vec<u8>> {
|
fn get_runtime_data() -> anyhow::Result<Vec<u8>> {
|
||||||
let mut hasher = std::collections::hash_map::DefaultHasher::new();
|
let mut hasher = std::collections::hash_map::DefaultHasher::new();
|
||||||
hasher.write(b"neutauri_runtime");
|
hasher.write(b"neutauri_runtime");
|
||||||
std::time::SystemTime::now().hash(&mut hasher);
|
std::time::SystemTime::now().hash(&mut hasher);
|
||||||
|
@ -35,10 +36,11 @@ fn get_runtime_data() -> io::Result<Vec<u8>> {
|
||||||
)?;
|
)?;
|
||||||
// let mut updater = rcedit::ResourceUpdater::new();
|
// let mut updater = rcedit::ResourceUpdater::new();
|
||||||
// updater.load(&temp_path).unwrap(); // TODO: handle error
|
// updater.load(&temp_path).unwrap(); // TODO: handle error
|
||||||
fs::read(&temp_path)
|
|
||||||
|
fs::read(&temp_path).with_context(|| format!("Failed to read {}", temp_path.display()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bundle(config_path: String) -> io::Result<()> {
|
pub fn bundle(config_path: String) -> anyhow::Result<()> {
|
||||||
let config_path = std::path::Path::new(&config_path).canonicalize()?;
|
let config_path = std::path::Path::new(&config_path).canonicalize()?;
|
||||||
let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str())
|
let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str())
|
||||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||||
|
|
|
@ -59,7 +59,7 @@ fn print_help_and_exit(args: Args) {
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> wry::Result<()> {
|
fn main() -> anyhow::Result<()> {
|
||||||
let args = std::env::args().collect::<Vec<_>>();
|
let args = std::env::args().collect::<Vec<_>>();
|
||||||
let args = Args::parse_args(&args[1..], gumdrop::ParsingStyle::default()).unwrap_or_else(|e| {
|
let args = Args::parse_args(&args[1..], gumdrop::ParsingStyle::default()).unwrap_or_else(|e| {
|
||||||
eprintln!("{}: {}", args[0], e);
|
eprintln!("{}: {}", args[0], e);
|
||||||
|
|
Loading…
Reference in New Issue