Correctly handle a few more mis-identified locales

This commit is contained in:
Yorhel 2021-12-16 13:44:39 +01:00
parent c6f53fb0fb
commit d19c56f285
2 changed files with 18 additions and 3 deletions

View file

@ -32,10 +32,15 @@ pub fn parse_path(path: &str) -> Option<(&str, &str, &str)> {
} }
let cap = match RE.captures(path) { Some(x) => x, None => return None }; let cap = match RE.captures(path) { Some(x) => x, None => return None };
let locale = cap.get(1).map(|e| e.as_str()).unwrap_or(""); let mut locale = cap.get(1).map(|e| e.as_str()).unwrap_or("");
let name = cap.get(2).unwrap().as_str(); let name = cap.get(2).unwrap().as_str();
let section = cap.get(3).unwrap().as_str(); let section = cap.get(3).unwrap().as_str();
// Some weird directories that happen to match the locale
if locale.contains("openmpi") || locale.contains("mpich") || locale.contains("mvapich") {
locale = "";
}
// Not everything matching the regex is necessarily a man page, exclude some special cases. // Not everything matching the regex is necessarily a man page, exclude some special cases.
match (name, section, locale) { match (name, section, locale) {
// Files that totally aren't man pages // Files that totally aren't man pages
@ -47,9 +52,10 @@ pub fn parse_path(path: &str) -> Option<(&str, &str, &str)> {
(_, "bz2", _) | (_, "bz2", _) |
(_, "xz", _) | (_, "xz", _) |
(_, "html", _) => None, (_, "html", _) => None,
// Some weird directories that happen to match the locale // Some more weird directories that happen to match the locale
(n, s, "5man") | (n, s, "5man") |
(n, s, "c") | (n, s, "c") |
(n, s, "man") |
(n, s, "man1") | (n, s, "man1") |
(n, s, "man2") | (n, s, "man2") |
(n, s, "man3") | (n, s, "man3") |
@ -59,7 +65,8 @@ pub fn parse_path(path: &str) -> Option<(&str, &str, &str)> {
(n, s, "man7") | (n, s, "man7") |
(n, s, "man8") | (n, s, "man8") |
(n, s, "Man-Part1") | (n, s, "Man-Part1") |
(n, s, "Man-Part2") => Some((n, s, "")), (n, s, "Man-Part2") |
(n, s, "overrides") => Some((n, s, "")),
// Nothing special! // Nothing special!
x => Some(x) x => Some(x)
} }

View file

@ -0,0 +1,8 @@
-- 'overrides' is not a valid locale. Rather, that was a directory that CentOS
-- used for updated man pages without overwriting the pages already installed
-- on the system.
-- 'man' is just a badly nested directory.
-- The others are openmpi using non-standard directories for some reason.
WITH b(id) AS (SELECT id FROM locales WHERE locale IN('man', 'overrides') OR locale ~ '(openmpi|mpich|mvapich)'),
f AS (UPDATE files SET locale = 0 WHERE locale IN(SELECT id FROM b))
DELETE FROM locales WHERE id IN(SELECT id FROM b);