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

Consider normalizing file paths on Windows to Unix style #10871

Closed
ror3d opened this issue Feb 9, 2024 · 5 comments
Closed

Consider normalizing file paths on Windows to Unix style #10871

ror3d opened this issue Feb 9, 2024 · 5 comments

Comments

@ror3d
Copy link
Contributor

ror3d commented Feb 9, 2024

Is your suggestion for improvement related to a problem? Please describe.
From what I could gather reading the code, paths on Windows for linked files are kept with backslash \ and those are escaped as \\ to avoid problems, as colons in URLs are escaped with backslash.

This can cause problems if sharing the database across different OSs.

Describe the solution you'd like
Since windows supports file paths with forward slash /, and to avoid issues of paths not working when sharing the database across systems with different OS, it might be best to convert any local file path to unix style.

@koppor
Copy link
Member

koppor commented Feb 23, 2024

@ror3d We had some internal discussions about that a while ago. Some were in favour of keeping it OS specific, some.not. Pro keeping it was to avoid confusion at newbies using their local library only. Moreover, when comfiguring a user specific file directory, it is "their" file directory on their OS and should be kept. Java perfectly handles / and \ in paths.

Please also think of backward compatibility. Noz everyone updates JabRef instantly. When JabRef "normalizes" everything, users of older versions cannot open the file again. They will ask why the team introduced the change. Only because there could be issues? I don't remember any one reporting issues there.

What about other tools such as Zotero relying on JabRef's format. Do you want to force them to change their code, too? To implement migrations? Handling both versions?

I know that the current implementation is a WTF for programmers. But please think of the users!!

Finally, some changes could be done at a complete new file field. See
#98. JabRef can do this once.in a decade due to other scripts and tooling relying on that format. That change needs to be well thought of.

Therefore closing as not planned. We can exhange more arguments here to also improve the next iteration of the file handling.

@koppor koppor closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2024
@ror3d
Copy link
Contributor Author

ror3d commented Feb 26, 2024

Actually, I was just testing this, and right now I don't recall how I had reproduced paths having backward slashes. I believe at some point I had a file showing with them, but maybe I got mistaken by some other part of the file (in the settings section maybe), because testing now I found that these paths are already converted to forward slashes. The normalization is happening in the LinkedFile.setLink, from changes from 2017:

    public void setLink(String link) {
        if (!isOnlineLink(link)) {
            this.link.setValue(link.replace("\\", "/"));
        } else {
            this.link.setValue(link);
        }
    }

So yeah, apparently it's already as I hoped. Sorry for the trouble.

@koppor
Copy link
Member

koppor commented Feb 29, 2024

@ror3d Thank you for checking. While writing, I was thinking, we had that thing... -- But I did not check. - If you see that "wrong" path again, please comment so that we can track down... I am a bit sure that I also saw it at some place...

@koppor
Copy link
Member

koppor commented Mar 5, 2024

Path with backslashes may be from BetterBibTeX Zotero Plugin

#10959 (comment)

@koppor
Copy link
Member

koppor commented May 13, 2024

Related issues:

Maybe not happening in recent versions, but we need to check.

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

No branches or pull requests

3 participants