Bug 565637 - FileAlreadyExistsException symlink $HOME/.config
Summary: FileAlreadyExistsException symlink $HOME/.config
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 5.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-29 06:37 EDT by Chris Coutinho CLA
Modified: 2020-08-23 05:14 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Coutinho CLA 2020-07-29 06:37:48 EDT
The getXDGConfigHome method of the org.eclipse.jgit.util.SystemReader class raises an exception if the config path already exists but is not a directory.

The SystemReader getXDGConfigHome method attempts to create the $HOME/.config directory using createDirectories, which does not fail if the 'directory' already exists, but on my system $HOME/.config is a symlink to a directory somewhere else.

https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createDirectories(java.nio.file.Path,%20java.nio.file.attribute.FileAttribute...)
Comment 1 Thomas Wolf CLA 2020-07-29 08:49:05 EDT
This is https://bugs.openjdk.java.net/browse/JDK-8130464 . :-(

Java lacks a Files.createDirectories() that would follow symlinks.
Comment 2 Eclipse Genie CLA 2020-07-29 08:53:08 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/167001
Comment 3 Thomas Wolf CLA 2020-08-22 17:03:36 EDT
(In reply to Eclipse Genie from comment #2)
> New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/167001

Superseded by https://git.eclipse.org/r/c/jgit/jgit/+/168096 . Turns out that trying to create the directory at that time is wrong anyway. It should be created only when JGit tries to write a file there, and code for that already exists and uses a variation that will also work with symlinks.