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

The directory pattern is not considered when checking if a file can be moved #7908

Closed
1 task done
k3KAW8Pnf7mkmdSMPHz27 opened this issue Jul 14, 2021 · 14 comments · Fixed by #8244
Closed
1 task done
Labels
external files good first issue An issue intended for project-newcomers. Varies in difficulty.

Comments

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

JabRef version on

JabRef 5.3--2021-07-14--477118c
Mac OS X 10.15.7 x86_64 
Java 16.0.1 
JavaFX 16+8

Steps to reproduce the behavior:

  1. In Options -> Preferences -> Linked files, make sure that
    1.1. There is an absolute path for Main file directory
    1.2. Search and store files relative to library file location is OFF
    1.3. There is a non-empty File directory pattern (e.g., Debugging)
  2. Have an entry with a linked file and open the entry-editor
    2.1. If the linked file is in the Main file directory, the Move file to file directory will always be disabled (instead of giving the option to move the file to the correct directory)
    2.2. If the linked file is in the correct directory, the Move file to file directory is always enabled (even if it doesn't do anything, because it tries to move the file to the directory it is already in)

Skärmavbild 2021-07-13 kl  15 13 36

The

public boolean isGeneratedPathSameAsOriginal() {
Optional<Path> newDir = databaseContext.getFirstExistingFileDir(filePreferences);
Optional<Path> currentDir = linkedFile.findIn(databaseContext, filePreferences).map(Path::getParent);
BiPredicate<Path, Path> equality = (fileA, fileB) -> {
try {
return Files.isSameFile(fileA, fileB);
} catch (IOException e) {
return false;
}
};
return OptionalUtil.equals(newDir, currentDir, equality);
}

should probably add a suggested directory name to newDir, similar to

public String getSuggestedFileName() {
String oldFileName = fileEntry.getLink();
String extension = FileHelper.getFileExtension(oldFileName).orElse(fileEntry.getFileType());
return getSuggestedFileName(extension);
}

but using

public static String createDirNameFromPattern(BibDatabase database, BibEntry entry, String directoryNamePattern) {

The origin is this bug report is https://discourse.jabref.org/t/how-to-use-file-directory-pattern/2802/

@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 added external files good first issue An issue intended for project-newcomers. Varies in difficulty. labels Jul 14, 2021
@bfrodsham
Copy link

Hello!
I'm new to open-source contributions and would like to take on this issue. Any tips or recommendations for where to start would be appreciated! Thanks.

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

Hello @bfrodsham, welcome!

We have tried to gather quite a few resources for getting started in https://devdocs.jabref.org/contributing, and we strive to keep them up-to-date.

If you have any specific questions, there is the Gitter channel as well https://gitter.im/JabRef/jabref

I haven't spent enough time on this issue to know for sure where are the best starting points in the code, but the linked files and locations are where I would start.

And asking questions is definitively a good way of getting started :)

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

Oups, and probably the most important part, make sure you can replicate the problem in a running copy of JabRef!

@bfrodsham
Copy link

Hey @k3KAW8Pnf7mkmdSMPHz27,

I'm slowly moving along on the issue. In the free time I have to work on the issue, I've finally set up a workspace as given in the guide, and now I'm focusing on replicating the problem.

I'm trying to understand step two in your instructions. What would qualify as a linked file? Or do you have a sample linked file I could use? Also, 2.1 and 2.2 are describing the behaviors that need to be fixed, correct? I gather that if the linked file is in the main file directory, then the "move file to file directory" option should be enabled and if the linked file is already in the correct file directory, then the option should be disabled. Is that correct? Thanks in advance for your patience and guidance.

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

With linked file I meant an entry with the location of a file on the hard drive in the “file” field. I don't have access to a computer for a couple of days so I can't send an example.

I think the simplest way of creating an entry with a linked file might be using the web-search feature of JabRef and download the (often) linked pdf in the entry-editor. I am not sure but arxiv might be good for this.

Alternatively it should be possible to link any pdf manually in the entry editor, I believe there is a + button to the right of the file field.

And yes, you are interpreting 2.1 and 2.2 correctly. Different suggestions are also welcome if you think a different behavior would be better.

@elijahzucker
Copy link

I was looking into this and I was wondering if it was still open since its been so long.

@ruoyu-qian
Copy link
Contributor

Hi, I am a CS student. I was able to reproduce this issue. Can I work on it if it's still open?

@ThiloteE
Copy link
Member

ThiloteE commented Nov 9, 2021

It is a little bit embarassing to have to say this on behalf of the Jabref community, but if you don't receive an answer, i would think that this is a yes. Give it a week or so, if @elijahzucker or @bfrodsham don't answer within this period, i personally would give it a go. Giving them this grace period and giving them a chance to explain what they have done so far and if they are still working on it would be a good thing, because there just recently was a case where two people coincidentally worked on the same thing at the same time without knowing about each other, both assuming nobody else was working on it.

Since you are a student, you might have deadlines, so if you want to start immediately, choosing another good first issue is always an option. :-)

@bfrodsham
Copy link

@ruoyu-qian @ThiloteE Yes, sorry I never got around to finishing this up! I got busy with university and all. Please go right ahead!

@ruoyu-qian
Copy link
Contributor

Thanks for the quick response @bfrodsham.
Since @bfrodsham got back to us, I will start working on this then! Not sure if I could solve it, but I will give it a try. @ThiloteE

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

It is a little bit embarassing to have to say this on behalf of the Jabref community, but if you don't receive an answer, i would think that this is a yes.

I'd +1 this. Start by checking if there are any open PRs and if you can reproduce the behavior in your local setup. We try to be good about keeping the issues/PRs up-to-date but things don't always turn out as one would wish.

@elijahzucker sorry about this one, I missed it in my backlog :/

@elijahzucker
Copy link

I'm also stuck with college work so go ahead I'm not gonna have time to work on this.

@ruoyu-qian
Copy link
Contributor

Thanks @elijahzucker for letting me know!

@ruoyu-qian
Copy link
Contributor

Hi, I have submitted PR for review. Let me know if you have any questions or there are any improvements can be done. Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external files good first issue An issue intended for project-newcomers. Varies in difficulty.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants