Skip to content

FileUtil::relativize doesn't take symlinks into account #12995

@Krzmbrzl

Description

@Krzmbrzl

JabRef version

5.15 (latest release)

Operating system

GNU / Linux

Details on version and operating system

KDE Neon - based on Ubuntu 24.04

Checked with the latest development build (copy version output from About dialog)

  • I made a backup of my libraries before testing the latest development version.
  • I have tested the latest development version and the problem persists

Steps to reproduce the behaviour

Look at

if (file.startsWith(directory)) {
return directory.relativize(file);
}

Appendix

The effect of this is (among other things?) that when manually linking a PDF file to a bib entry, which is located in the main file directory, it can still end up being added by its full path.

This is because the configured main file directory and/or the path to the selected PDF file can contain symbolic links which make the paths appear different (which causes FileUtils::relativize to fail) even though they are not.

It seems that Path::toRealPath from Java's standard library could be used for obtaining a canonical path representation that has symlinks resolved.

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

In Progress

Status

Normal priority

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions