summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornamilsk <namilsk@namilsk.tech>2026-01-06 17:28:09 +0300
committernamilsk <namilsk@namilsk.tech>2026-01-06 17:28:09 +0300
commit0fb58ab610f1c9d546ace52184831495c8541fae (patch)
treea3b87966a9a590bb8d7f132d7a68b51ecf82626d
parent29a2a06ca874b646f60d29648399b07b76f7296f (diff)
Fixed issue with `Config::parse()` call if it not needed
-rw-r--r--.gitignore7
-rw-r--r--src/main.rs27
2 files changed, 23 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index 4f3c370..99c4c84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -81,8 +81,13 @@ dkms.conf
*.db
*.tar.gz
*.mesk
+repo/
+mesk
+*.mesk
+INDEX.toml
+
# because not full-implemented
doc/
# Deprecated files
-*.deprecated \ No newline at end of file
+*.deprecated
diff --git a/src/main.rs b/src/main.rs
index 4e1402d..dc238b1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -122,13 +122,8 @@ struct RemoteInstallArgs {
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
- let config = crate::cfg::config::Config::parse()?;
-
- init_router(&config).await?;
let cli: Cli = Cli::parse();
- let config = Arc::new(config);
-
let result = {
match &cli.command {
Commands::Validate { path } => {
@@ -170,7 +165,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Extracting archive...");
Package::extract_archive(pkgname)?;
- let config = Config::parse().unwrap();
+ let config = Config::parse()?;
let cache_dir = &config.paths.cache_dir;
// Find the package directory (should be name-version format)
@@ -226,7 +221,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Extracting archive...");
Package::extract_archive(pkgname)?;
- let config = Config::parse().unwrap();
+ let config = Config::parse()?;
let cache_dir = &config.paths.cache_dir;
let mut pkg_dir_name = None;
@@ -264,7 +259,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
pkg.install()?;
println!("Package '{}' installed successfully.", pkg.name);
} else {
- let config = Config::parse().unwrap();
+ let config = Config::parse()?;
+ // Initialize router if it's needed for I2P connections and is enabled
+ if !args.http && config.router.integrated_router {
+ init_router(&config).await?;
+ }
if args.http {
println!("Installing {} via HTTP", pkgname);
let mut http_client = HTTPPackage::new(config);
@@ -323,7 +322,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
Commands::GetSource { pkgname } => {
- let config = Config::parse().unwrap();
+ let config = Config::parse()?;
+ // Initialize router for I2P connections if enabled
+ if config.router.integrated_router {
+ init_router(&config).await?;
+ }
println!("Getting source of {}", pkgname);
let source_path = GitSource::get_source_by_name(pkgname, &config)?;
@@ -369,7 +372,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
return Ok(());
}
Commands::Update => {
- let config = Config::parse().unwrap();
+ let config = Config::parse()?;
+ // Initialize router for I2P connections if enabled
+ if config.router.integrated_router {
+ init_router(&config).await?;
+ }
println!("Updating index from {}", config.repo.repo_url);
let mut i2p_client = I2PPackage::new(config);