mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 08:12:44 +10:00
@ -3,7 +3,7 @@ use crate::db::{DatabaseImpls, DATA_ROOT_DIR};
|
|||||||
use crate::downloads::download_logic;
|
use crate::downloads::download_logic;
|
||||||
use crate::downloads::manifest::{DropDownloadContext, DropManifest};
|
use crate::downloads::manifest::{DropDownloadContext, DropManifest};
|
||||||
use crate::downloads::progress::ProgressChecker;
|
use crate::downloads::progress::ProgressChecker;
|
||||||
use crate::{AppState, DB};
|
use crate::DB;
|
||||||
use log::info;
|
use log::info;
|
||||||
use rustix::fs::{fallocate, FallocateFlags};
|
use rustix::fs::{fallocate, FallocateFlags};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|||||||
@ -56,7 +56,7 @@ pub async fn start_game_downloads(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
info!("Spawned download");
|
info!("Spawned download");
|
||||||
return Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn start_game_download(
|
pub fn start_game_download(
|
||||||
@ -92,5 +92,5 @@ pub async fn stop_specific_game_download(state: tauri::State<'_, Mutex<AppState>
|
|||||||
info!("Stopping callback");
|
info!("Stopping callback");
|
||||||
callback.store(true, Ordering::Release);
|
callback.store(true, Ordering::Release);
|
||||||
|
|
||||||
return Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -2,11 +2,10 @@ use crate::auth::generate_authorization_header;
|
|||||||
use crate::db::DatabaseImpls;
|
use crate::db::DatabaseImpls;
|
||||||
use crate::downloads::manifest::DropDownloadContext;
|
use crate::downloads::manifest::DropDownloadContext;
|
||||||
use crate::DB;
|
use crate::DB;
|
||||||
use gxhash::{gxhash128, GxHasher};
|
|
||||||
use log::info;
|
use log::info;
|
||||||
use md5::{Context, Digest};
|
use md5::{Context, Digest};
|
||||||
use reqwest::blocking::Response;
|
use reqwest::blocking::Response;
|
||||||
use std::{fs::{File, OpenOptions}, hash::Hasher, io::{self, BufReader, BufWriter, Error, ErrorKind, Read, Seek, SeekFrom, Write}, path::PathBuf, sync::{atomic::{AtomicBool, Ordering}, Arc}};
|
use std::{fs::{File, OpenOptions}, io::{self, Error, ErrorKind, Read, Seek, SeekFrom, Write}, path::PathBuf, sync::{atomic::{AtomicBool, Ordering}, Arc}};
|
||||||
use urlencoding::encode;
|
use urlencoding::encode;
|
||||||
|
|
||||||
pub struct DropFileWriter {
|
pub struct DropFileWriter {
|
||||||
@ -101,24 +100,4 @@ pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc<AtomicBool>)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stream.flush().unwrap();
|
// stream.flush().unwrap();
|
||||||
}
|
|
||||||
|
|
||||||
pub fn copy_to_drop_file_writer(response: &mut Response, writer: &mut DropFileWriter) {
|
|
||||||
loop {
|
|
||||||
info!("Writing to file writer");
|
|
||||||
let mut buf = [0u8; 1024];
|
|
||||||
response.read(&mut buf).unwrap();
|
|
||||||
match writer.write_all(&buf) {
|
|
||||||
Ok(_) => {},
|
|
||||||
Err(e) => {
|
|
||||||
match e.kind() {
|
|
||||||
ErrorKind::Interrupted => {
|
|
||||||
info!("Interrupted");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_ => { println!("{}", e); return;}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,8 +1,6 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::File;
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
|
|
||||||
pub type DropManifest = HashMap<String, DropChunk>;
|
pub type DropManifest = HashMap<String, DropChunk>;
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
#[derive(Serialize, Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||||
|
|||||||
Reference in New Issue
Block a user