INNER CODE UNIT · Rust

persist_manifest

HemantKArya/BloomeeTunes · rust/src/api/downloader/mod.rs:588

    fn persist_manifest(&self) {
        let tasks: Vec<PersistedDownloadTask> = match self.tasks.read() {
            Ok(g) => g.values().filter_map(|t| t.lock().ok()).map(|g| g.persisted.clone()).collect(),
            Err(_) => return,
        };

        if let Ok(json) = serde_json::to_string_pretty(&tasks) {
            let _ = std::fs::create_dir_all(&self.state_dir);
            let _ = atomic_write(&self.manifest_path, json.as_bytes());
        }
    }
}

/// Safety net: `reqwest::blocking::Client` owns an internal tokio runtime.
/// When FRB drops the opaque `DownloadManager` it does so from an async
/// worker thread.  Dropping the runtime inside another runtime panics with
/// "Cannot drop a runtime in a context where blocking is not allowed."
///

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…