Issue 9798: Relinking after moving#10526
Conversation
|
To ease organizational workflows I have linked the pull-request to the issue with syntax as described in https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
|
|
For testing you can create a temporary directory with junit's @tempdir annotation. Check out ohter tests. e.g MoveCleanup ... |
|
I've written my tests in |
koppor
left a comment
There was a problem hiding this comment.
I currently have only code style comments (it's late here)
The issue was about to integrate it in "Automatically set file links". See screenshot below. First step: Add a test case to It could be that your complete implementation needs to be rewritten to match the data structures of |
|
@koppor |
|
if you click on details in the pipeline runs, you will see the reason for the failure |
56fe294 to
de10192
Compare
| file.setLink(fileLocations.get(0)); | ||
| changedFiles.add(file); | ||
| } else { | ||
| exceptions.add(new IOException("couldn't find file: " + file.getLink())); |
There was a problem hiding this comment.
Isn't there a FileNotFoundException in Java?
| } | ||
| } | ||
| } | ||
| return new RelinkedResults(changedFiles, exceptions); |
There was a problem hiding this comment.
You collect filenot found only - why not just listing the filenames which are not found in a list?
| path = folder.resolve("CiteKey.pdf"); | ||
| A = folder.resolve("A"); | ||
| Files.createDirectory(A); | ||
| B = folder.resolve("B"); | ||
| Files.createDirectory(B); |
There was a problem hiding this comment.
Please do not modify all tests. Please move that initalization code to your tests (if possible)
| listLinked.add(linkedFile); | ||
| entry.setFiles(listLinked); | ||
|
|
||
| // Copy Bib file from A to B |
There was a problem hiding this comment.
It is a MOVE, not a copy, is it?
| // Copy Bib file from A to B | ||
| Path destination = B.resolve("CiteKey.pdf"); | ||
| Files.copy(A.resolve("CiteKey.pdf"), destination, StandardCopyOption.REPLACE_EXISTING); | ||
| Files.deleteIfExists(A.resolve("CiteKey.pdf")); |
There was a problem hiding this comment.
There should be another test where the file stays the same.
In test code, it is very OK to have duplicated code fragments.
| } | ||
| List<String> output = new ArrayList<>(); | ||
| for (Path p : paths) { | ||
| output.add(p.toString()); |
There was a problem hiding this comment.
String datatype should be used as last resort. Please return List<Path> and convert to string at the very last possibility. This enables strong typing.
|
I did not see any more activity in this PR. Thus, I close it. In case you resume work, pelase feel free to re-open this PR. |
We added file relinking functionality after a file is moved when clicking the "Automatically set file links" button. Implementation based and improved upon work done in closed issue [JabRef#10526]. [JabRef#9798]

Fixes #9798
I've created
AutomaticRelink.javaandAutomaticRelinkTest.java, I wasn't too sure where they were meant to be so they are in the appropriate org.jabref directoryI've started writing some tests in
AutomaticRelinkTest.javabut was strugglingI tried using the creating test directories section, but it wasn't working for me 😢
This PR is mostly to show I've started working on the problem and to hopefully get some understanding about how linking works!
Mandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if applicable)