summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorqvkap <qvkapp@gmail.com>2026-09-05 08:29:46 +0300
committerqvkap <qvkapp@gmail.com>2026-09-05 08:29:46 +0300
commit74c76bb5cea8ff70153a8f9ebe02df6ffb0205f7 (patch)
tree7dd16b620d79f579a3ddf4da29e7a55fb585af2f /src/main.rs
parent22f9abec46c28f50df2c19b134da88848942c168 (diff)
downloadror-74c76bb5cea8ff70153a8f9ebe02df6ffb0205f7.tar.gz
ror-74c76bb5cea8ff70153a8f9ebe02df6ffb0205f7.zip
fix: dependency resolution, update file removal and sync TLS validation
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs153
1 files changed, 69 insertions, 84 deletions
diff --git a/src/main.rs b/src/main.rs
index 4e326f0..c2725ee 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -230,10 +230,22 @@ async fn main() {
let db = install::InstalledDB::load();
- for pkg_name in &packages {
- if pkg_name.starts_with('@') {
- continue;
+ let mut all_packages = Vec::new();
+ for item in packages {
+ if let Some(group_name) = item.strip_prefix('@') {
+ match group::load_group(group_name) {
+ Ok(grp) => all_packages.extend(grp.packages),
+ Err(e) => {
+ eprintln!("{} Failed to load group '{}': {}", "[ror]".red().bold(), group_name, e);
+ return;
+ }
+ }
+ } else {
+ all_packages.push(item);
}
+ }
+
+ for pkg_name in &all_packages {
let is_local = pkg_name.starts_with('/')
|| pkg_name.starts_with("./")
|| pkg_name.ends_with(".ror")
@@ -247,62 +259,40 @@ async fn main() {
}
}
- if packages[0].starts_with('@') {
-
- let group_name = &packages[0][1..];
- match group::load_group(group_name) {
- Ok(group) => {
- if let Err(e) = parallel::install_packages_parallel(
- &group.packages,
- Arc::clone(&cfg),
- )
- .await
- {
- eprintln!("{} {}", "[ror]".red().bold(), e);
- }
- }
- Err(e) => eprintln!("{} {}", "[ror]".red().bold(), e),
- }
- } else {
-
- let (local_pkgs, remote_pkgs): (Vec<String>, Vec<String>) = packages
- .iter()
- .cloned()
- .partition(|p| {
- p.starts_with('/')
- || p.starts_with("./")
- || p.ends_with(".ror")
- || p.ends_with(".sror")
- });
-
-
- for path_str in &local_pkgs {
- install::install_local_package(
- std::path::Path::new(path_str),
- &cfg,
- );
- }
+ let (local_pkgs, remote_pkgs): (Vec<String>, Vec<String>) = all_packages
+ .into_iter()
+ .partition(|p| {
+ p.starts_with('/')
+ || p.starts_with("./")
+ || p.ends_with(".ror")
+ || p.ends_with(".sror")
+ });
+
+ for path_str in &local_pkgs {
+ install::install_local_package(
+ std::path::Path::new(path_str),
+ &cfg,
+ );
+ }
- let remote_pkgs: Vec<String> = remote_pkgs.into_iter().map(|p| {
- let (name, variant) = install::parse_package_spec(&p);
- install::resolve_package_name(&name).map(|canonical| {
- match variant {
- Some(v) => format!("{}{{{}}}", canonical, v),
- None => canonical,
- }
- }).unwrap_or(p)
- }).collect();
-
-
- if !remote_pkgs.is_empty() {
- if let Err(e) = parallel::install_packages_parallel(
- &remote_pkgs,
- Arc::clone(&cfg),
- )
- .await
- {
- eprintln!("{} {}", "[ror]".red().bold(), e);
+ let remote_pkgs: Vec<String> = remote_pkgs.into_iter().map(|p| {
+ let (name, variant) = install::parse_package_spec(&p);
+ install::resolve_package_name(&name).map(|canonical| {
+ match variant {
+ Some(v) => format!("{}{{{}}}", canonical, v),
+ None => canonical,
}
+ }).unwrap_or(p)
+ }).collect();
+
+ if !remote_pkgs.is_empty() {
+ if let Err(e) = parallel::install_packages_parallel(
+ &remote_pkgs,
+ Arc::clone(&cfg),
+ )
+ .await
+ {
+ eprintln!("{} {}", "[ror]".red().bold(), e);
}
}
}
@@ -378,22 +368,29 @@ fn run_di(del_pkg: String, inst_pkg: String, cfg: Arc<config::Config>) {
inst_pkg
);
- let del_pkg_c = del_pkg.clone();
- let inst_pkg_c = inst_pkg.clone();
- let cfg_c = Arc::clone(&cfg);
-
- let del_handle = std::thread::spawn(move || {
- delete::remove_package_files_only(&del_pkg_c, &record_files)
- });
+ let installed_pkg = match install::install_package_with_result(&inst_pkg, &cfg) {
+ Ok(pkg) => pkg,
+ Err(e) => {
+ eprintln!(
+ "{} Failed to install '{}': {}. Old package remains intact.",
+ "[ror]".red().bold(),
+ inst_pkg,
+ e
+ );
+ return;
+ }
+ };
- let inst_handle = std::thread::spawn(move || {
- install::install_package_with_result(&inst_pkg_c, &cfg_c)
- });
+ let new_files: std::collections::HashSet<_> = installed_pkg.files.iter().collect();
+ let obsolete_files: Vec<_> = record_files.into_iter()
+ .filter(|f| !new_files.contains(f))
+ .collect();
- let del_ok = del_handle.join().unwrap_or(false);
- let inst_result = inst_handle
- .join()
- .unwrap_or_else(|_| Err("panicked".to_string()));
+ let del_ok = if obsolete_files.is_empty() {
+ true
+ } else {
+ delete::remove_package_files_only(&del_pkg, &obsolete_files)
+ };
let mut db = install::InstalledDB::load();
@@ -401,19 +398,7 @@ fn run_di(del_pkg: String, inst_pkg: String, cfg: Arc<config::Config>) {
db.packages.remove(&del_pkg);
}
- match inst_result {
- Ok(p) => {
- db.add_package(p);
- }
- Err(e) => {
- eprintln!(
- "{} Failed to install '{}': {}",
- "[ror]".red().bold(),
- inst_pkg,
- e
- );
- }
- }
+ db.add_package(installed_pkg);
if let Err(e) = db.save() {
eprintln!("{} Failed to save DB: {}", "[ror]".red().bold(), e);