mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-18 18:51:16 +10:00
fix: Download chunks with wrong indexes
Migrated to using checksums as indexes instead Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@ -36,7 +36,7 @@ pub struct GameDownloadAgent {
|
||||
pub version: String,
|
||||
pub control_flag: DownloadThreadControl,
|
||||
contexts: Mutex<Vec<DropDownloadContext>>,
|
||||
completed_contexts: Mutex<SliceDeque<usize>>,
|
||||
completed_contexts: Mutex<SliceDeque<String>>,
|
||||
pub manifest: Mutex<Option<DropManifest>>,
|
||||
pub progress: Arc<ProgressObject>,
|
||||
sender: Sender<DownloadManagerSignal>,
|
||||
@ -260,7 +260,7 @@ impl GameDownloadAgent {
|
||||
let progress_handle = ProgressHandle::new(progress, self.progress.clone());
|
||||
|
||||
// If we've done this one already, skip it
|
||||
if self.completed_contexts.lock().unwrap().contains(&index) {
|
||||
if self.completed_contexts.lock().unwrap().contains(&context.checksum) {
|
||||
progress_handle.skip(context.length);
|
||||
continue;
|
||||
}
|
||||
@ -299,7 +299,7 @@ impl GameDownloadAgent {
|
||||
"Finished context #{} with checksum {}",
|
||||
index, context.checksum
|
||||
);
|
||||
completed_indexes.push(index);
|
||||
completed_indexes.push(context.checksum.clone());
|
||||
}
|
||||
Ok(false) => {
|
||||
debug!(
|
||||
@ -321,7 +321,7 @@ impl GameDownloadAgent {
|
||||
let completed_lock_len = {
|
||||
let mut completed_contexts_lock = self.completed_contexts.lock().unwrap();
|
||||
for (_, item) in newly_completed.iter() {
|
||||
completed_contexts_lock.push_front(*item);
|
||||
completed_contexts_lock.push_front(item.clone());
|
||||
}
|
||||
|
||||
completed_contexts_lock.len()
|
||||
|
||||
@ -2,12 +2,12 @@ use std::{fs::File, io::{Read, Write}, path::PathBuf};
|
||||
|
||||
use log::{error, warn};
|
||||
use native_model::{Decode, Encode};
|
||||
use serde_binary::binary_stream::Endian;
|
||||
|
||||
pub type DropData = v1::DropData;
|
||||
|
||||
static DROP_DATA_PATH: &str = ".dropdata";
|
||||
|
||||
|
||||
pub mod v1 {
|
||||
use std::{path::PathBuf, sync::Mutex};
|
||||
|
||||
@ -19,7 +19,7 @@ pub mod v1 {
|
||||
pub struct DropData {
|
||||
game_id: String,
|
||||
game_version: String,
|
||||
pub completed_contexts: Mutex<Vec<usize>>,
|
||||
pub completed_contexts: Mutex<Vec<String>>,
|
||||
pub base_path: PathBuf,
|
||||
}
|
||||
|
||||
@ -78,10 +78,10 @@ impl DropData {
|
||||
Err(e) => error!("{}", e),
|
||||
};
|
||||
}
|
||||
pub fn set_completed_contexts(&self, completed_contexts: &[usize]) {
|
||||
pub fn set_completed_contexts(&self, completed_contexts: &[String]) {
|
||||
*self.completed_contexts.lock().unwrap() = completed_contexts.to_owned();
|
||||
}
|
||||
pub fn get_completed_contexts(&self) -> Vec<usize> {
|
||||
pub fn get_completed_contexts(&self) -> Vec<String> {
|
||||
self.completed_contexts.lock().unwrap().clone()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user