mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
copy direct to disk
This commit is contained in:
@ -6,7 +6,7 @@
|
|||||||
Load Data
|
Load Data
|
||||||
</button>
|
</button>
|
||||||
<input placeholder="GAME ID" v-model="gameId" />
|
<input placeholder="GAME ID" v-model="gameId" />
|
||||||
<input placehodler="VERSION NAME" v-model="versionName" />
|
<input placeholder="VERSION NAME" v-model="versionName" />
|
||||||
<button
|
<button
|
||||||
class="w-full rounded-md p-4 bg-blue-600 text-white"
|
class="w-full rounded-md p-4 bg-blue-600 text-white"
|
||||||
@click="requestGameWrapper"
|
@click="requestGameWrapper"
|
||||||
@ -24,8 +24,9 @@ async function requestGame() {
|
|||||||
await invoke("start_game_download", {
|
await invoke("start_game_download", {
|
||||||
gameId: gameId.value,
|
gameId: gameId.value,
|
||||||
gameVersion: versionName.value,
|
gameVersion: versionName.value,
|
||||||
maxThreads: 4,
|
maxThreads: 12,
|
||||||
});
|
});
|
||||||
|
console.log("Requested game from FE");
|
||||||
}
|
}
|
||||||
function requestGameWrapper() {
|
function requestGameWrapper() {
|
||||||
console.log("Wrapper started");
|
console.log("Wrapper started");
|
||||||
|
|||||||
@ -37,7 +37,9 @@ pub fn download_game_chunk(ctx: DropDownloadContext) {
|
|||||||
.expect("Failed to seek to file offset");
|
.expect("Failed to seek to file offset");
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut stream = BufWriter::with_capacity(1024 * 1024, file);
|
// let mut stream = BufWriter::with_capacity(1024, file);
|
||||||
|
|
||||||
response.copy_to(&mut stream).unwrap();
|
response.copy_to(&mut file).unwrap();
|
||||||
|
|
||||||
|
// stream.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ use std::fs::{create_dir_all, File};
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::atomic::AtomicUsize;
|
use std::sync::atomic::AtomicUsize;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
@ -138,6 +139,7 @@ pub fn generate_job_contexts(
|
|||||||
let mut contexts = Vec::new();
|
let mut contexts = Vec::new();
|
||||||
let base_path = DATA_ROOT_DIR.join("games").join(game_id.clone()).clone();
|
let base_path = DATA_ROOT_DIR.join("games").join(game_id.clone()).clone();
|
||||||
create_dir_all(base_path.clone()).unwrap();
|
create_dir_all(base_path.clone()).unwrap();
|
||||||
|
info!("Generating contexts");
|
||||||
for (raw_path, chunk) in manifest {
|
for (raw_path, chunk) in manifest {
|
||||||
let path = base_path.join(Path::new(raw_path));
|
let path = base_path.join(Path::new(raw_path));
|
||||||
|
|
||||||
@ -147,7 +149,7 @@ pub fn generate_job_contexts(
|
|||||||
let file = File::create(path.clone()).unwrap();
|
let file = File::create(path.clone()).unwrap();
|
||||||
let mut running_offset = 0;
|
let mut running_offset = 0;
|
||||||
|
|
||||||
for i in 0..chunk.ids.len() {
|
for (i, length) in chunk.lengths.iter().enumerate() {
|
||||||
contexts.push(DropDownloadContext {
|
contexts.push(DropDownloadContext {
|
||||||
file_name: raw_path.to_string(),
|
file_name: raw_path.to_string(),
|
||||||
version: version.to_string(),
|
version: version.to_string(),
|
||||||
@ -156,11 +158,12 @@ pub fn generate_job_contexts(
|
|||||||
game_id: game_id.to_string(),
|
game_id: game_id.to_string(),
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
});
|
});
|
||||||
running_offset += chunk.lengths[i] as u64;
|
running_offset += *length as u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
fallocate(file, FallocateFlags::empty(), 0, running_offset);
|
fallocate(file, FallocateFlags::empty(), 0, running_offset).unwrap();
|
||||||
}
|
}
|
||||||
|
info!("Finished generating");
|
||||||
contexts
|
contexts
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,8 +191,7 @@ pub async fn start_game_download(
|
|||||||
let contexts = generate_job_contexts(&local_manifest, game_version.clone(), game_id);
|
let contexts = generate_job_contexts(&local_manifest, game_version.clone(), game_id);
|
||||||
|
|
||||||
download_manager
|
download_manager
|
||||||
.begin_download(max_threads, contexts)
|
.begin_download(max_threads, contexts)?;
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user