biliget 0.6.9

简单的B站视频下载工具 支持免登录下载B站高清视频
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::path::{Path, PathBuf};
use std::sync::{LazyLock, Mutex};

static TEMP_FILE_LIST: LazyLock<Mutex<Vec<PathBuf>>> = LazyLock::new(|| Mutex::new(Vec::new()));

pub fn add_temp_file(file: &Path) {
    let mut temp_file_list = TEMP_FILE_LIST.lock().unwrap();
    temp_file_list.push(file.to_path_buf());
}

pub fn drop_temp_file() {
    let mut temp_file_list = TEMP_FILE_LIST.lock().unwrap();
    for file in temp_file_list.iter() {
        std::fs::remove_file(file).ok();
    }
    temp_file_list.clear();
}