fix match inside import_file()
This commit is contained in:
16
src/main.rs
16
src/main.rs
@ -1,7 +1,6 @@
|
||||
use postgres::{Client, NoTls};
|
||||
use std::{
|
||||
env::args,
|
||||
error::Error,
|
||||
fs::{self, File},
|
||||
io::{self, BufRead, BufReader, Write},
|
||||
};
|
||||
@ -173,11 +172,18 @@ fn import_file(client: &mut postgres::Client, file: Option<String>) {
|
||||
let input_file = File::open(filename).unwrap();
|
||||
let reader_iter = BufReader::new(input_file).lines();
|
||||
|
||||
if File::open("Fucked.txt").is_ok() {
|
||||
if File::open("Fucked.txt.bak").is_ok() {
|
||||
fs::remove_file("Fucked.txt.bak").unwrap();
|
||||
}
|
||||
|
||||
fs::rename("Fucked.txt", "Fucked.txt.bak").unwrap();
|
||||
}
|
||||
|
||||
let mut fucked_file = match File::create_new("Fucked.txt") {
|
||||
Ok(file) => file,
|
||||
Err(error) => {
|
||||
let message = error.to_string();
|
||||
eprintln!("Problem creating the file: {message}");
|
||||
Err(err) => {
|
||||
eprintln!("Problem creating the file: {}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
@ -191,7 +197,7 @@ fn import_file(client: &mut postgres::Client, file: Option<String>) {
|
||||
}
|
||||
|
||||
match client.query_one("SELECT insert_url($1);", &[&line]) {
|
||||
Ok(_) => break,
|
||||
Ok(_) => (),
|
||||
Err(_) => {
|
||||
writeln!(fucked_file, "{}", line).unwrap();
|
||||
}
|
||||
|
Reference in New Issue
Block a user