-
-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
basic implementation of XDG base directory for alt folder #876
Conversation
Hi @DutchO7, thanks for the pull request! Could you please elaborate and provide some more context around this change? Specifically, what would the benefits for the end user be? Does the default Also, it would be helpful if you could provide some detailed testing steps for this PR so I can validate the changes. Thanks! |
Hi @Alexander01998, thank you for replying! The main purpose of this change is to adhere to the XDG base directory standard, it helps to keep the users home directory clean and organized by storing programs files in directories specified by the standard. The For testing, you can set the environment variable If the environment variable If you would like to learn more about the XDG base directory standard, you can find some more information about it here. I hope this is enough to explain my changes, I apologize for not going into detail earlier, please let me know if there is anything else that I could explain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DutchO7, thanks for the additional context. The implementation of the XDG base directory standard sounds like a useful addition. However, I see a potential issue with implementing it in the way you've proposed.
If a user already has their XDG_DATA_HOME
variable set and they are updating from a previous version of Wurst, they may already have the encryption files stored in their home folder. In this case, the new version of Wurst would be unable to find these files in the XDG directory, causing the AltManager to fail to decrypt the user's alt list and act as if the file is corrupted.
To mitigate this issue, consider implementing a migration process that checks for the presence of the encryption files in the home folder and moves them to the new XDG directory if the XDG_DATA_HOME
variable is set. This way, existing users will not lose their alt data during the update process.
Let me know your thoughts on this approach, and if you have any other suggestions or concerns.
Hi @Alexander01998, thank you for your feedback. I have implemented a migration process that will move the files from the The code will check if the new This way, users who upgrade to a new version and have the I apologize for taking so long, Java is not my first language, but please let me know if you have any more concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @DutchO7, that was super quick – no worries at all!
I've taken a look at your updated changes and tested it out. However, a few concerns have come up:
-
Files.move()
is only intended for moving a single file or an empty directory. It can't recursively move a directory with all of its contents. This approach may sometimes work due to optimizations in the file system, but it's not reliable. For example, the migration will fail ifXDG_DATA_HOME
is on a different drive thanuser.home
. -
The
Files.exists()
check is performed twice: once inWurstClient.initialize()
and again inEncryption.migrateEncryptionFolder()
. It would be more efficient to do this check only once, and perhaps useFiles.isDirectory()
instead to ensure the target is indeed a directory. -
The migration note that gets placed in the user's home directory seems counterproductive, since the essence of XDG is to keep the home directory uncluttered.
-
I suggest using the same ".Wurst Encryption" folder name across both locations for consistency.
I hope you find time to make these improvements. Your work is much appreciated!
Hi @Alexander01998, thank you for your feedback, I appricate you taking the time to consider and review my code! I have made some changes based on your concerns:
Thank you again for taking the time to provide feedback on my code, please let me know if you have any more concerns. |
WalkthroughThe changes introduced in this pull request primarily focus on the migration of the encryption folder for alt files in the Wurst client. The new code determines the location of the encryption folder based on the Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Files selected for processing (2)
- src/main/java/net/wurstclient/WurstClient.java (2 hunks)
- src/main/java/net/wurstclient/altmanager/Encryption.java (2 hunks)
Additional comments (Suppressed): 3
src/main/java/net/wurstclient/WurstClient.java (2)
26-26: The new import
net.wurstclient.altmanager.Encryption
is used for the encryption folder migration functionality. Ensure that this class is correctly implemented and tested.148-161: This block of code checks if the
XDG_DATA_HOME
environment variable is set and not empty. If it is, it sets the encryption folder to a new location based on this variable. If the new encryption folder does not exist and the old one does, it calls themigrateEncryptionFolder
method from theEncryption
class to migrate the files. If theXDG_DATA_HOME
environment variable is not set or is empty, it defaults to the old encryption folder location. This is a significant change in how the application handles file storage and could potentially impact users who have custom configurations or scripts relying on the old path. It's important to communicate this change clearly to users and provide instructions for manually migrating files if necessary.src/main/java/net/wurstclient/altmanager/Encryption.java (1)
- 14-18: The new imports
java.io.File
andjava.nio.file.StandardCopyOption
are necessary for the file migration process in the newmigrateEncryptionFolder
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Files selected for processing (2)
- src/main/java/net/wurstclient/WurstClient.java (3 hunks)
- src/main/java/net/wurstclient/altmanager/Encryption.java (3 hunks)
Files skipped from review due to trivial changes (1)
- src/main/java/net/wurstclient/WurstClient.java
Description
Added basic support for XDG base directory, if the environment variable
XDG_DATA_HOME
is set then alts and encryption will be stored in$XDG_DATA_HOME/WurstClient/
, else it will just store in.Wurst encryption
, in the home directory.Summary by CodeRabbit
XDG_DATA_HOME
environment variable, enhancing compatibility with different system configurations.