-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[WIP] This relativizes the PDF's filepaths after importing through "Find Unlinked Files" #10582
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c588571
Relativize filepath if "General file directory" property present
IceMajor2 27bd000
Extend method with MetaData object
IceMajor2 65b3ef7
Fix failing checkstyle task (add space)
IceMajor2 18c9014
Use "first existing file directory" preference to relativize file path"
IceMajor2 59a2343
Remove Optional wrapper from the Path parameter
IceMajor2 6cb13fc
Rename a variable
IceMajor2 9730180
Merge branch 'main' into fix-for-issue-549
IceMajor2 f09dbbe
Add test which checks for PDF filepath relativization when working di…
IceMajor2 6a424cd
Use Builder pattern and change the way a collection is created
IceMajor2 b73faaf
Remove else branch
IceMajor2 e6f87d0
Add JavaDoc for the importDatabase(Path, Path) explaining the working…
IceMajor2 0597f06
Merge branch 'main' into fix-for-issue-549
IceMajor2 30a305a
Merge branch 'main' into fix-for-issue-549
IceMajor2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,20 @@ public ParserResult importDatabase(String data) throws IOException { | |
|
||
@Override | ||
public ParserResult importDatabase(Path filePath) throws IOException { | ||
return importDatabase(filePath, null); | ||
} | ||
|
||
/** | ||
* Same as {@link PdfMergeMetadataImporter#importDatabase(Path)}, but this | ||
* relativizes the {@code filePath}, if {@code workingDir} is not null | ||
* (otherwise no path modification happens). | ||
* | ||
* @param filePath the path to the file which should be imported | ||
* @param workingDir one of the directories | ||
* {@link BibDatabaseContext#getFileDirectories(FilePreferences) mentioned here} | ||
* set up for this database | ||
*/ | ||
public ParserResult importDatabase(Path filePath, Path workingDir) throws IOException { | ||
List<BibEntry> candidates = new ArrayList<>(); | ||
|
||
for (Importer metadataImporter : metadataImporters) { | ||
|
@@ -124,7 +138,9 @@ public ParserResult importDatabase(Path filePath) throws IOException { | |
} | ||
} | ||
} | ||
|
||
if (workingDir != null) { | ||
filePath = workingDir.relativize(filePath); | ||
} | ||
Comment on lines
+141
to
+143
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Call The required |
||
entry.addFile(new LinkedFile("", filePath, StandardFileType.PDF.getName())); | ||
return new ParserResult(List.of(entry)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JabRef's logic of storing files is more complicated.
JabRef searchers in EACH directory, not in ONE.
See org.jabref.logic.util.io.FileUtil#getListOfLinkedFiles.