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