trim + fixes

This commit is contained in:
pivodevat
2025-09-18 12:21:01 +03:00
parent 35fafb1ca6
commit 28ba2135ec
10 changed files with 139 additions and 25 deletions

0
src/utils/env.rs Normal file
View File

View File

@ -76,7 +76,7 @@ fn hardcopy(
})?;
} else if metadata.file_type().is_symlink() {
let symlink_value = fs::read_link(source)?;
fs::remove_file(destination)?;
if destination.exists() { fs::remove_file(destination)? }
unix::fs::symlink(symlink_value, destination)?;
}

0
src/utils/hooks.rs Normal file
View File

View File

@ -1,5 +1,4 @@
use std::fs;
use std::env;
use std::io::{self, BufRead};
use std::path::{Path,PathBuf};
@ -59,10 +58,12 @@ pub fn get_patch_script<P: AsRef<Path>>(file_path: P) -> io::Result<String> {
extract_block(file_path, "``` sh *** config ***", "```")
}
pub fn get_trim_rules<P: AsRef<Path>>(file_path: P) -> io::Result<String> {
extract_block(file_path, "``` cfg *** Trim rules ***", "```")
}
pub fn get_repo_list() -> io::Result<Vec<String>> {
let file_path = crate::commands::get_var_path().join("aeropkg.md");
let file_path = crate::commands::get_etc_path().join("aeropkg.md");
let block = extract_block(file_path, "``` cfg *** Repository list and priority ***", "```")?;
@ -82,13 +83,9 @@ pub fn get_repo_list() -> io::Result<Vec<String>> {
pub fn get_repo_addr(repo: &str) -> io::Result<String> {
let exe_path = env::current_exe()?;
let file_path = exe_path
.parent()
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "Failed to get executable directory"))?
.join("../etc/aeropkg.md");
let file_path = crate::commands::get_etc_path().join("aeropkg.md");
let block = extract_block(file_path, "``` sh *** Repository list and priority ***", "```")?;
let block = extract_block(file_path, "``` cfg *** Repository list and priority ***", "```")?;
for line in block.lines() {
let trimmed_line = line.trim();