// Depending on used backend, either delete the store.json or delete all files
Depending on used backend, either delete the store.json or delete all files
Depending on used backend either delete the store . json or delete all files
fn clean_up(backend: u8, path: String) {
    if backend == BACKEND_JSON {
        // for JSON backend delete store
        let store_path: String = format!("{}/store.json", path);
        if !Path::new(&store_path).exists() {
            println!("Nothing to clean up.");
            return;
        }
        match fs::remove_file(store_path.clone()) {
            Ok(_o) => println!("Clean-up store at {} done.", store_path),
            Err(_e) => eprintln!("Cleaning up store failed."),
        }
    } else if backend == BACKEND_FILE {
        // for File backend delete meta data and files
        if !Path::new(&path).exists() {
            println!("Nothing to clean up.");
            return;
        }
        match fs::remove_dir_all(path.clone()) {
            Ok(_o) => println!("Deleted all file in {} done.", path),
            Err(_e) => eprintln!("Deleting all file in {} failed.", path),
        }
    } else {
        eprintln!("Backend unknown");
    }
}
fn clean_up ( backend : u8 , path : String ) { if backend == BACKEND_JSON { // for JSON backend delete store let store_path : String = format ! ( " " path ) ; if ! Path :: new ( & store_path ) . exists ( ) { println ! ( " " ) ; return ; } match fs :: remove_file ( store_path . clone ( ) ) { Ok ( _o ) => println ! ( " " store_path ) , Err ( _e ) => eprintln ! ( " " ) , } } else if backend == BACKEND_FILE { // for File backend delete meta data and files if ! Path :: new ( & path ) . exists ( ) { println ! ( " " ) ; return ; } match fs :: remove_dir_all ( path . clone ( ) ) { Ok ( _o ) => println ! ( " " path ) , Err ( _e ) => eprintln ! ( " " path ) , } } else { eprintln ! ( " " ) ; } }
Depending on used backend, either delete the store.json or delete all files
Depending on used backend either delete the store . json or delete all files
backend
u8
path
String