From de4a40cbff298b0c7838a7163dbc37c4623287f4 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Thu, 3 Oct 2019 20:47:49 -0300 Subject: [PATCH 1/2] added patchfiles directory check --- src/patch/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/patch/main.rs b/src/patch/main.rs index 875105c..e02e3c0 100644 --- a/src/patch/main.rs +++ b/src/patch/main.rs @@ -378,6 +378,17 @@ impl Iterator for SendFileIterator { fn main() { println!("[patch] starting server"); + match std::fs::read_dir("patchfiles/") { + Ok(_) => {}, + Err(_) => { + match std::fs::create_dir("patchfiles/") { + Ok(_) => {}, + Err(_) => { + panic!("Could not create patchfiles directory!"); + }, + } + }, + } let (patch_file_tree, patch_file_lookup) = generate_patch_tree("patchfiles/"); println!("[patch] files to patch:"); let mut indent = 0; From e7fed195384698d9d520562fc518d197e0342bc9 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Thu, 3 Oct 2019 23:12:44 -0300 Subject: [PATCH 2/2] replace matches with if lets --- src/patch/main.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/patch/main.rs b/src/patch/main.rs index e02e3c0..d9f3c0f 100644 --- a/src/patch/main.rs +++ b/src/patch/main.rs @@ -378,16 +378,10 @@ impl Iterator for SendFileIterator { fn main() { println!("[patch] starting server"); - match std::fs::read_dir("patchfiles/") { - Ok(_) => {}, - Err(_) => { - match std::fs::create_dir("patchfiles/") { - Ok(_) => {}, - Err(_) => { - panic!("Could not create patchfiles directory!"); - }, - } - }, + if let Err(_) = std::fs::read_dir("patchfiles/") { + if let Err(_) = std::fs::create_dir("patchfiles/") { + panic!("Could not create patchfiles directory!"); + } } let (patch_file_tree, patch_file_lookup) = generate_patch_tree("patchfiles/"); println!("[patch] files to patch:");