Skip to content
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

Fix file path intercompatibility for Windows and POSIX systems #315

Closed

Conversation

searinminecraft
Copy link

@searinminecraft searinminecraft commented Jul 12, 2024

Fixes #298

This fixes a bug where if you move a library saved on Windows to Linux or any POSIX operating system, it will cause the files to not be found due to backslashes. This is a hack I done to prevent this from happening.

Needs extensive testing though, even though that I have confirmed this fix works and does not crash Tag Studio.

cc @coolesding

@searinminecraft searinminecraft changed the title Fix intercompatibility for Windows and POSIX systems Fix file path intercompatibility for Windows and POSIX systems Jul 12, 2024
@CyanVoxel CyanVoxel added Type: Bug Something isn't working as intended Type: File System File system interactions Status: Review Needed A review of this is needed labels Jul 17, 2024
@searinminecraft
Copy link
Author

Well thats a concern.. putting Path() on it would just make the bug return. (it becomes \ again, making the as_posix() useless). Is there any other thing i can do?

@CyanVoxel CyanVoxel added this to the Alpha 9.4 milestone Jul 19, 2024
@CyanVoxel
Copy link
Member

Since Windows-style backslashes are valid characters in Posix paths, it makes things a bit tricky.

I would say the best course of action to fix #298 would be to always save and load file paths inside of ts_library.json as Posix paths moving forward, regardless of the OS. In addition there would need to be consideration for libraries saved with versions before this fix (currently 9.3.2 and earlier) - I propose replacing any "" characters with "/" in older library saves. This would, however, break data inside of anyone's libraries on Posix systems that currently contain file entries that use backslashes as legitimate file characters. I believe this can be avoided by performing a "file exists" check on both the old and new file paths, and only performing the conversion in cases where the swapped path comes back valid. If both cases come back false, then there's an existing unlinked entry that can't be broken any further from us messing with it.

@CyanVoxel CyanVoxel removed the Status: Review Needed A review of this is needed label Jul 19, 2024
@searinminecraft searinminecraft deleted the fs-intercompat branch July 22, 2024 08:53
@searinminecraft
Copy link
Author

I have no motivation in trying to fix this. Sorry...

@CyanVoxel CyanVoxel removed this from the Alpha 9.4 milestone Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as intended Type: File System File system interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: File Paths not Intercompatible between Windows and Linux
2 participants