Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ fn clean_aur(

fn fix_perms(file: &Path) -> Result<()> {
let pkg = file.join("pkg");
let mut perms = pkg.metadata()?.permissions();
let metadata = pkg.symlink_metadata()?;
if !metadata.is_dir() {
return Ok(());
}
let mut perms = metadata.permissions();
perms.set_mode(0o755);
set_permissions(pkg, perms)?;
Ok(())
Expand Down Expand Up @@ -168,11 +172,7 @@ fn clean_aur_pkg(
}
}

do_remove(
config,
&config.fetch.clone_dir.join(srcinfo.base.pkgbase),
rm,
)
do_remove(config, &file.path(), rm)
}

fn do_remove(config: &Config, path: &Path, rm: bool) -> Result<()> {
Expand Down
22 changes: 18 additions & 4 deletions src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,21 +513,35 @@ pub async fn show_comments(config: &mut Config) -> Result<i32> {

if config.sort_mode.is_top_down(false) {
for (title, comment) in iter.into_iter() {
print_indent(c.bold, 0, 0, config.cols, " ", title.split_whitespace());
print_indent(
c.bold,
0,
0,
config.cols,
" ",
title.split_whitespace().map(escape_control),
);

for line in comment.trim().split('\n') {
let line = line.split_whitespace();
let line = line.split_whitespace().map(escape_control);
print!(" ");
print_indent(Style::new(), 4, 4, config.cols, " ", line);
}
println!();
}
} else {
for (title, comment) in iter.into_iter().rev() {
print_indent(c.bold, 0, 0, config.cols, " ", title.split_whitespace());
print_indent(
c.bold,
0,
0,
config.cols,
" ",
title.split_whitespace().map(escape_control),
);

for line in comment.trim().split('\n') {
let line = line.split_whitespace();
let line = line.split_whitespace().map(escape_control);
print!(" ");
print_indent(Style::new(), 4, 4, config.cols, " ", line);
}
Expand Down
12 changes: 10 additions & 2 deletions src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,21 @@ pub fn link_str(enabled: bool, s: &str, url: &str) -> String {
}

pub fn escape_control(s: &str) -> Cow<'_, str> {
if !s.chars().any(char::is_control) {
escape_controls(s, char::is_control)
}

pub fn escape_control_multiline(s: &str) -> Cow<'_, str> {
escape_controls(s, |c| c.is_control() && c != '\n' && c != '\t')
}

fn escape_controls(s: &str, is_control: impl Fn(char) -> bool) -> Cow<'_, str> {
if !s.chars().any(&is_control) {
return Cow::Borrowed(s);
}

let mut escaped = String::with_capacity(s.len());
for c in s.chars() {
if c.is_control() {
if is_control(c) {
escaped.extend(c.escape_default());
} else {
escaped.push(c);
Expand Down
Loading
Loading