INNER CODE UNIT · Rust

restore_tasks

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

    pub async fn restore_tasks(&self) -> Result<Vec<DownloadTaskSnapshot>, String> {
        let path = Path::new(&self.manifest_path);
        if !path.exists() {
            self.emit(DownloadManagerEvent::RecoverySummary { restored: 0, cleaned: 0 });
            return Ok(Vec::new());
        }

        let raw = tokio::fs::read_to_string(path)
            .await
            .map_err(|e| format!("Failed to read download manifest: {e}"))?;

        let all_raw: Vec<PersistedDownloadTask> = serde_json::from_str(&raw)
            .map_err(|e| format!("Corrupt download manifest: {e}"))?;

        // Deduplicate by task_id (first occurrence wins) to guard against
        // any manifest corruption that might produce repeated entries.
        let mut seen_ids = HashSet::new();
        let mut all: Vec<PersistedDownloadTask> = Vec::with_capacity(all_raw.len());

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…