|
|
|
@@ -8,7 +8,7 @@ signal update_completed
|
|
|
|
|
signal update_failed(error: String)
|
|
|
|
|
signal rollback_completed
|
|
|
|
|
|
|
|
|
|
const BACKUP_COUNT := 2 # Keep this many backup versions
|
|
|
|
|
const BACKUP_COUNT := 2 # Keep this many backup versions
|
|
|
|
|
|
|
|
|
|
func apply_update(downloaded_pck_path: String, version: String) -> void:
|
|
|
|
|
emit_signal("update_started")
|
|
|
|
@@ -91,7 +91,7 @@ func _copy_file(from: String, to: String) -> bool:
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
# Copy in chunks for large files
|
|
|
|
|
const CHUNK_SIZE := 1024 * 1024 # 1MB chunks
|
|
|
|
|
const CHUNK_SIZE := 1024 * 1024 # 1MB chunks
|
|
|
|
|
while source.get_position() < source.get_length():
|
|
|
|
|
var chunk := source.get_buffer(CHUNK_SIZE)
|
|
|
|
|
dest.store_buffer(chunk)
|
|
|
|
@@ -121,7 +121,7 @@ func _cleanup_old_backups(backup_dir: String, keep_count: int) -> void:
|
|
|
|
|
|
|
|
|
|
# Remove oldest backups if we have too many
|
|
|
|
|
while backups.size() > keep_count:
|
|
|
|
|
var old_backup := backups.pop_front()
|
|
|
|
|
var old_backup = backups.pop_front()
|
|
|
|
|
dir.remove(old_backup)
|
|
|
|
|
print("[UpdateApplier] Removed old backup: ", old_backup)
|
|
|
|
|
|
|
|
|
@@ -151,7 +151,7 @@ func rollback_to_backup() -> bool:
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
|
|
backups.sort()
|
|
|
|
|
var latest_backup := backups.back()
|
|
|
|
|
var latest_backup = backups.back()
|
|
|
|
|
|
|
|
|
|
# Restore the backup
|
|
|
|
|
if _copy_file(backup_dir + latest_backup, game_dir + pck_name):
|
|
|
|
|