Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Backup save related files outside of save folder #178

Merged
merged 16 commits into from
Feb 11, 2025

Conversation

DarkShadow44
Copy link
Contributor

This includes:

  • journeymap data
  • NEI data
  • TCNodeTracker data
  • visualprospecting data
  • schematics
  • blueprints

Fixes #120

Note that I don't know what exactly is stored inside blueprints, I never used it

@Dream-Master Dream-Master requested review from Lyfts and a team January 22, 2025 16:19
@Lyfts
Copy link
Member

Lyfts commented Jan 22, 2025

Have you tested how restoring a backup from the in-game menu interacts with this?

@YannickMG
Copy link

I feel like this feature could help enable seamless in-place pack updates.

@DarkShadow44
Copy link
Contributor Author

I pushed a rework, addressing the mentioned issues. I still need to test it more before I consider it ready, though.

@Lyfts
Copy link
Member

Lyfts commented Jan 23, 2025

Windows doesn't seem to like those wildcards

java.nio.file.InvalidPathException: Illegal char <*> at index 54: journeymap/data/sp/New World-------------------------/**
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:199) ~[?:?]
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:175) ~[?:?]
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) ~[?:?]
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92) ~[?:?]
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:231) ~[?:?]
	at java.base/java.nio.file.Path.of(Path.java:148) ~[?:?]
	at java.base/java.nio.file.Paths.get(Paths.java:69) ~[?:?]
	at Launch//serverutils.task.backup.ThreadBackup.addBaseFolderFiles(ThreadBackup.java:77) ~[ThreadBackup.class:?]
	at Launch//serverutils.task.backup.ThreadBackup.doBackup(ThreadBackup.java:97) [ThreadBackup.class:?]
	at Launch//serverutils.task.backup.ThreadBackup.run(ThreadBackup.java:67) [ThreadBackup.class:?]

This includes by default:
- journeymap data
- NEI data
- TCNodeTracker data
- visualprospecting data
- schematics
- blueprints
@DarkShadow44
Copy link
Contributor Author

Windows doesn't seem to like those wildcards

java.nio.file.InvalidPathException: Illegal char <*> at index 54: journeymap/data/sp/New World-------------------------/**
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:199) ~[?:?]
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:175) ~[?:?]
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) ~[?:?]
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92) ~[?:?]
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:231) ~[?:?]
	at java.base/java.nio.file.Path.of(Path.java:148) ~[?:?]
	at java.base/java.nio.file.Paths.get(Paths.java:69) ~[?:?]
	at Launch//serverutils.task.backup.ThreadBackup.addBaseFolderFiles(ThreadBackup.java:77) ~[ThreadBackup.class:?]
	at Launch//serverutils.task.backup.ThreadBackup.doBackup(ThreadBackup.java:97) [ThreadBackup.class:?]
	at Launch//serverutils.task.backup.ThreadBackup.run(ThreadBackup.java:67) [ThreadBackup.class:?]

Seems like Windows java doesn't like "*" in the paths, I pushed an update that should fix that. Although I can't fully test since I currently can't test on Windows.

@Lyfts
Copy link
Member

Lyfts commented Jan 23, 2025

Stripping the path of all * makes the VP subfolder end up as $WORLDNAME_ which isn't gonna match up with any directory.

Also all those force pushes makes it very hard to track what was actually changed.

@DarkShadow44
Copy link
Contributor Author

Stripping the path of all * makes the VP subfolder end up as $WORLDNAME_ which isn't gonna match up with any directory.

I only remove the * for the String rootFolder = String.valueOf(Paths.get(cleaned_pattern).getName(0));, this is just to get the root folder, which shouldn't have wildcards to begin with.

Also all those force pushes makes it very hard to track what was actually changed.

Sorry, I'm used to gitlab where that is no problem, I will make additional commits from now on.

@Lyfts
Copy link
Member

Lyfts commented Jan 25, 2025

I only remove the * for the String rootFolder = String.valueOf(Paths.get(cleaned_pattern).getName(0));, this is just to get the root folder, which shouldn't have wildcards to begin with.

If you're only using the PathMatcher to resolve the wildcards it would be much more efficient to only resolve the part of the path that contains a wildcard, instead of trying to match every file in the root folder against the pattern.

Doing it this way means that it'll iterate through potentially thousands of files, since all content of the subfolders is included, to only add a few of those files to the backup.
For the NEI folders in my dev instance it iterated through the entire saves folder which was over 3000 files and it only ended up adding 1 file to the backup.
I also tried checking a more extreme example by adding ./options.txt to the additional backup files and this ended up iterating through > 10000 files to only add a single one.

@DarkShadow44
Copy link
Contributor Author

DarkShadow44 commented Jan 25, 2025

I only remove the * for the String rootFolder = String.valueOf(Paths.get(cleaned_pattern).getName(0));, this is just to get the root folder, which shouldn't have wildcards to begin with.

If you're only using the PathMatcher to resolve the wildcards it would be much more efficient to only resolve the part of the path that contains a wildcard, instead of trying to match every file in the root folder against the pattern.

Doing it this way means that it'll iterate through potentially thousands of files, since all content of the subfolders is included, to only add a few of those files to the backup. For the NEI folders in my dev instance it iterated through the entire saves folder which was over 3000 files and it only ended up adding 1 file to the backup. I also tried checking a more extreme example by adding ./options.txt to the additional backup files and this ended up iterating through > 10000 files to only add a single one.

Thanks for your in-depth review, appreciate it! I pushed a fix that only iterates as many files as needed.

Could you please open conversations for future issue? I find it to be easier to follow, since it groups.

@DarkShadow44
Copy link
Contributor Author

DarkShadow44 commented Feb 3, 2025

Also added compatibility for older backups, any help in testing would be appreciated though.
For testing the old config would be best:

S:additional_backup_files <
        journeymap/data/sp/$WORLDNAME/**
        TCNodeTracker/$WORLDNAME/**"
        saves/NEI/global/**
        saves/NEI/local/$WORLDNAME/**
        visualprospecting/client/*/$WORLDNAME_*/**
        visualprospecting/server/$WORLDNAME_*/**
        visualprospecting/veintypesLUT
        schematics/**
        blueprints/**
     >

@Dream-Master Dream-Master requested a review from Lyfts February 3, 2025 19:36
@Dream-Master Dream-Master requested review from Caedis and a team February 3, 2025 19:36
@Dream-Master Dream-Master added the 🚧 Testing on Zeta Do not merge yet, testing this PR on Zeta label Feb 3, 2025
(cherry picked from commit cb39d02)
Copy link
Member

@Lyfts Lyfts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, I just have a few minor points left.

@Lyfts Lyfts enabled auto-merge (squash) February 11, 2025 17:01
@Lyfts Lyfts merged commit 034b237 into GTNewHorizons:master Feb 11, 2025
1 check passed
@serenibyss serenibyss removed the 🚧 Testing on Zeta Do not merge yet, testing this PR on Zeta label Feb 14, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Journeymap folder to backup
6 participants