Skip to content

Commit

Permalink
Merge pull request #93 from seriouscatsoserious/srs-branch
Browse files Browse the repository at this point in the history
Reset everything fix
  • Loading branch information
seriouscatsoserious authored Jun 11, 2024
2 parents 7c5f874 + 8e9d72d commit dc5fdcd
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions autoloads/appstate.gd
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ func purge(base_dir: String) -> void:


func purge_all(base_dir: String):
delete_zcash_directory()
delete_ethereum_directory()
#
#delete_zcash_directory()
#delete_ethereum_directory()
#
var dir = DirAccess.open(base_dir)
if dir:
dir.list_dir_begin()
Expand Down Expand Up @@ -458,31 +460,35 @@ func setup_wallets_backup_directory():
dir_access.list_dir_end()
else:
print("Failed to access user data directory.")
return backup_dir_path
return backup_dir_path



func reset_everything(preserve_wallets: bool = true):
var user_data_dir = OS.get_user_data_dir()
for i in chain_states:
chain_states[i].stop_chain()
await get_tree().create_timer(0.1).timeout
remove_child(chain_states[i])
chain_states[i].cleanup()

if preserve_wallets:
backup_wallets()
print("Backing up wallets and starting reset process...")
delete_zcash_directory()
delete_ethereum_directory()
purge_except_backup(user_data_dir, "wallets_backup")
else:
print("Purging everything, including wallets...")

delete_zcash_directory()
delete_ethereum_directory()
purge_all(user_data_dir) # This will delete everything, including the wallets backup
# After a full purge, there is nothing left to do, so return from the function.
print("Full purge completed successfully.")

# If preserve_wallets is true, the function continues with the remaining reset process.

# Remaining operations on chains and configurations.
for i in chain_states:
chain_states[i].stop_chain()
await get_tree().create_timer(0.1).timeout
remove_child(chain_states[i])
chain_states[i].cleanup()

if OS.get_name() == "Windows":
print("Executing Windows-specific cleanup...")
Expand Down

0 comments on commit dc5fdcd

Please sign in to comment.