src/global/functions/init_move.rs

28 lines · 928 bytes

 1use std::fs;
 2
 3use home::home_dir;
 4
 5pub fn init_move() {
 6    let home_dir = home_dir().unwrap();
 7    let store_dir = home_dir.join(".local/share/youtube-tui/");
 8    let cache_dir = home_dir.join(".cache/youtube-tui");
 9
10    let store_info_dir = store_dir.join("info/");
11    let cache_info_dir = cache_dir.join("info/");
12    fs::read_dir(store_info_dir).unwrap().for_each(|entry| {
13        let entry = entry.unwrap().path();
14        let _ = fs::rename(&entry, cache_info_dir.join(entry.file_name().unwrap()));
15    });
16
17    let store_thumbnails_dir = store_dir.join("thumbnails/");
18    let cache_thumbnails_dir = cache_dir.join("thumbnails/");
19    fs::read_dir(store_thumbnails_dir)
20        .unwrap()
21        .for_each(|entry| {
22            let entry = entry.unwrap().path();
23            let _ = fs::rename(
24                &entry,
25                cache_thumbnails_dir.join(entry.file_name().unwrap()),
26            );
27        });
28}