diff options
| author | metamuffin <metamuffin@disroot.org> | 2022-09-29 16:54:49 +0200 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2022-09-29 16:54:49 +0200 |
| commit | eda0c12b4af72935c9fa6adef60aff754313f189 (patch) | |
| tree | 7d6ffdf17564e36320fefe818b0267c43332f0a9 /src | |
| parent | b31b6ff2ab5d94e5b6280ba3cb4db7d46267999a (diff) | |
| download | staticwiki-eda0c12b4af72935c9fa6adef60aff754313f189.tar staticwiki-eda0c12b4af72935c9fa6adef60aff754313f189.tar.bz2 staticwiki-eda0c12b4af72935c9fa6adef60aff754313f189.tar.zst | |
blub
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs index e8c0375..34b00bb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,10 +43,6 @@ fn main() { for (i, result) in parse_mediawiki_dump::parse(input).enumerate() { match result { - Err(error) => { - eprintln!("xml format error: {}", error); - break; - } Ok(page) => { if page.namespace == 0 && match &page.format { @@ -81,17 +77,27 @@ fn main() { let mut header = Header::new_gnu(); header.set_size(html.as_bytes().len() as u64); header.set_cksum(); - archive - .append_data(&mut header, filename, html.as_bytes()) - .unwrap(); + if let Err(e) = archive.append_data(&mut header, filename, html.as_bytes()) + { + eprintln!("could not append to archive: {e}") + } } else { - let mut f = File::create(format!("out/{}", filename)).unwrap(); - f.write_all(html.as_bytes()).unwrap() + match File::create(format!("out/{}", filename)) { + Ok(mut f) => f.write_all(html.as_bytes()).unwrap(), + Err(e) => eprintln!("could not create file: {e}"), + } } - } else { + } else if args.verbose { eprintln!("page ignored: {:?}", page.title); } } + Err(error) => { + eprintln!("xml format error: {}", error); + break; + } + } + if i % 10000 == 0 { + eprintln!("{i}") } if Some(i) == args.limit { break; |