fix replace mode not working
This commit is contained in:
19
src/app.rs
19
src/app.rs
@@ -305,14 +305,7 @@ I'm sure I've checked the list, press Enter to continue"#,
|
|||||||
let chunk_path = game_dir.join(chunk_name.to_string());
|
let chunk_path = game_dir.join(chunk_name.to_string());
|
||||||
let output_path = if use_replace_mode {
|
let output_path = if use_replace_mode {
|
||||||
// In replace mode, first generate a temporary decompressed file
|
// In replace mode, first generate a temporary decompressed file
|
||||||
let temp_path = chunk_path.with_extension("pak.temp");
|
chunk_path.with_extension("pak.temp")
|
||||||
// Backup the original file
|
|
||||||
let backup_path = chunk_path.with_extension("pak.backup");
|
|
||||||
if backup_path.exists() {
|
|
||||||
fs::remove_file(&backup_path)?;
|
|
||||||
}
|
|
||||||
fs::rename(&chunk_path, &backup_path)?;
|
|
||||||
temp_path
|
|
||||||
} else {
|
} else {
|
||||||
// In patch mode
|
// In patch mode
|
||||||
// Find the max patch id for the current chunk series
|
// Find the max patch id for the current chunk series
|
||||||
@@ -348,8 +341,16 @@ I'm sure I've checked the list, press Enter to continue"#,
|
|||||||
true,
|
true,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// In replace mode, rename the temporary file to the original file name
|
// In replace mode, backup the original file
|
||||||
|
// and rename the temporary file to the original file name
|
||||||
if use_replace_mode {
|
if use_replace_mode {
|
||||||
|
// Backup the original file
|
||||||
|
let backup_path = chunk_path.with_extension("pak.backup");
|
||||||
|
if backup_path.exists() {
|
||||||
|
fs::remove_file(&backup_path)?;
|
||||||
|
}
|
||||||
|
fs::rename(&chunk_path, &backup_path)?;
|
||||||
|
// Rename the temporary file to the original file name
|
||||||
fs::rename(&output_path, &chunk_path)?;
|
fs::rename(&output_path, &chunk_path)?;
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
|
Reference in New Issue
Block a user