Skip to content

fix(save_manager): traverse remote folders with recursion#42

Merged
a1ex4 merged 3 commits into
a1ex4:developfrom
CortezSMz:fix-retrieve-saves
Sep 26, 2023
Merged

fix(save_manager): traverse remote folders with recursion#42
a1ex4 merged 3 commits into
a1ex4:developfrom
CortezSMz:fix-retrieve-saves

Conversation

@CortezSMz
Copy link
Copy Markdown

@CortezSMz CortezSMz commented Sep 20, 2023

Description

With this pull request you should be able to backup any folder from the switch regardles of the folder structure, even if heavily nested.

Fixes #41 and should also fix #18 and #23

Motivations:

Most games don't have a convention for folder structure on save data, making it impossible to guess how deep you have too look for save files.

Solution:

Traverse the folders with recursion while checking if it's a file and keeping track of current path and it's children. It also ignores empty foldes.

How has this been tested?

Tested with the following shop_config.tml:

folders = [
    {local = "Saves/Xance/Tinfoil", remote = "/switch/tinfoil/saves"},
    {local = "Saves/Xance/DBI", remote = "/switch/DBI/saves"},
    {local = "Saves/Xance/JKSV", remote = "/JKSV"},
    {local = "Album/Xance", remote = "/emuMMC/SD00/Nintendo/Album"},
    {local = "Album/Xance", remote = "/Nintendo/Album"},
]

Console output:

2023-09-20 16:42:03,599 - INFO apscheduler.scheduler: Added job "Backup saves" to job store "default"
2023-09-20 16:42:03,599 - INFO apscheduler.scheduler: Scheduler started
2023-09-20 16:42:03,608 - INFO apscheduler.executors.default: Running job "Backup saves (trigger: interval[0:10:00], next run at: 2023-09-20 16:42:03 UTC)" (scheduled at 2023-09-20 16:42:03.586925+00:00)
2023-09-20 16:42:03,658 - INFO save_manager: Successfully connected to Switch device on host 192.168.1.9.
2023-09-20 16:42:03,659 - INFO save_manager: Retrieving saves from from /switch/tinfoil/saves to Saves/Xance/Tinfoil
2023-09-20 16:42:04,142 - INFO save_manager: Retrieved 1 saves in 0.483s - from /switch/tinfoil/saves to Saves/Xance/Tinfoil
2023-09-20 16:42:04,142 - INFO save_manager: Retrieving saves from from /switch/DBI/saves to Saves/Xance/DBI
2023-09-20 16:42:04,225 - INFO save_manager: Retrieved 0 saves in 0.083s - from /switch/DBI/saves to Saves/Xance/DBI
2023-09-20 16:42:04,225 - INFO save_manager: Retrieving saves from from /JKSV to Saves/Xance/JKSV
2023-09-20 16:43:40,613 - INFO save_manager: Retrieved 291 saves in 96.388s - from /JKSV to Saves/Xance/JKSV
2023-09-20 16:43:40,614 - INFO save_manager: Retrieving saves from from /emuMMC/SD00/Nintendo/Album to Album/Xance
2023-09-20 16:44:19,622 - INFO save_manager: Retrieved 72 saves in 29.008s - from /emuMMC/SD00/Nintendo/Album to Album/Xance
2023-09-20 16:44:19,623 - INFO save_manager: Retrieving saves from from /Nintendo/Album to Album/Xance
2023-09-20 16:44:28,218 - INFO save_manager: Retrieved 29 saves in 8.595s - from /Nintendo/Album to Album/Xance
2023-09-20 16:44:28,219 - INFO apscheduler.executors.default: Job "Backup saves (trigger: interval[0:10:00], next run at: 2023-09-20 16:52:03 UTC)" executed successfully

@CortezSMz CortezSMz marked this pull request as ready for review September 20, 2023 19:05
@a1ex4
Copy link
Copy Markdown
Owner

a1ex4 commented Sep 26, 2023

Even if I can't test this currently, this looks good to me. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Saves Manager fails to backup files and attempts to reconnect indefinitely Automatic Save Backup Issue

2 participants