indexer: Fix bug in Contents file parsing + decrease cron verbosity

Turns out that not all Contents files heave a header.
This commit is contained in:
Yorhel 2016-11-27 10:48:32 +01:00
parent eb15b6e2c7
commit b79ecfb284
2 changed files with 9 additions and 10 deletions

View file

@ -18,21 +18,20 @@ fn get_contents(f: Option<open::Path>) -> Result<HashSet<String>> {
let rd = archive::Archive::open_raw(&mut fd)?;
let brd = BufReader::new(rd);
let mut pkgs = HashSet::new();
let mut filecnt = -1;
let mut filecnt = 0;
let mut mancnt = 0;
for line in brd.split(b'\n') {
let line = line?;
let line = match str::from_utf8(&line) { Ok(x) => x, _ => continue };
if line.starts_with("FILE ") {
filecnt = 0;
continue;
} else if filecnt < 0 {
let mut it = line.split(' ');
let pkg = it.next_back().unwrap();
if !pkg.contains('/') || pkg == "LOCATION" {
continue;
}
filecnt += 1;
let mut it = line.split(' ');
let pkg = it.next_back().unwrap();
let path = it.fold(String::new(), |acc, x| acc + " " + x);
if man::ismanpath(&path.trim()) {
mancnt += 1;
@ -42,7 +41,7 @@ fn get_contents(f: Option<open::Path>) -> Result<HashSet<String>> {
}
}
debug!("Found {}/{} man files in {} relevant packages from {}", mancnt, filecnt, pkgs.len(), f.path);
info!("Found {}/{} man files in {} relevant packages from {}", mancnt, filecnt, pkgs.len(), f.path);
Ok(pkgs)
}

View file

@ -2,8 +2,8 @@ test -f .config && source ./.config
index() {
echo "====> indexer -vv $@"
./indexer -vv $@ 2>&1
echo "====> indexer -v $@"
./indexer -v $@ 2>&1
echo
}