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

Refine main directory not found error message #9625

Merged

Conversation

HoussemNasri
Copy link
Member

@HoussemNasri HoussemNasri commented Feb 18, 2023

Closes #8010

Question: The error is still showing when saving preferences even after choosing to store files relative to the library location. Is this the correct behavior?

image

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@Siedlerchr
Copy link
Member

This Documents folder should only be used as fallback directory when no directory is set (/e.g. newcomers of jabref) and no other options are set.

We must trigger the validation only when the main file directory is selected
grafik

#9113

/**
* Look up the directories set up for this database.
* There can be up to four directories definitions for these files:
* <ol>
* <li>next to the .bib file.</li>
* <li>the preferences can specify a default one.</li>
* <li>the database's metadata can specify a general directory.</li>
* <li>the database's metadata can specify a user-specific directory.</li>
* </ol>
* <p>
* The settings are prioritized in the following order, and the first defined setting is used:
* <ol>
* <li>user-specific metadata directory</li>
* <li>general metadata directory</li>
* <li>BIB file directory (if configured in the preferences AND none of the two above directories are configured)</li>
* <li>preferences directory (if .bib file directory should not be used according to the preferences)</li>
* </ol>
*
* @param preferences The fileDirectory preferences
*/
public List<Path> getFileDirectories(FilePreferences preferences) {
List<Path> fileDirs = new ArrayList<>();
// 1. Metadata user-specific directory
metaData.getUserFileDirectory(preferences.getUser())
.ifPresent(userFileDirectory -> fileDirs.add(getFileDirectoryPath(userFileDirectory)));
// 2. Metadata general directory
metaData.getDefaultFileDirectory()
.ifPresent(metaDataDirectory -> fileDirs.add(getFileDirectoryPath(metaDataDirectory)));
// 3. BIB file directory or Main file directory
// fileDirs.isEmpty in the case, 1) no user-specific file directory and 2) no general file directory is set
// (in the metadata of the bib file)
if (fileDirs.isEmpty() && preferences.shouldStoreFilesRelativeToBibFile()) {
getDatabasePath().ifPresent(dbPath -> {
Path parentPath = dbPath.getParent();
if (parentPath == null) {
parentPath = Path.of(System.getProperty("user.dir"));
}
Objects.requireNonNull(parentPath, "BibTeX database parent path is null");
fileDirs.add(parentPath);
});
} else {
// Main file directory
preferences.getMainFileDirectory().ifPresent(fileDirs::add);
}
return fileDirs.stream().map(Path::toAbsolutePath).collect(Collectors.toList());
}

@HoussemNasri
Copy link
Member Author

We can now merge this and open a new issue to track down why the default snap path was invalid in the first place.

@Siedlerchr Siedlerchr merged commit 76b221d into JabRef:main Feb 22, 2023
@HoussemNasri HoussemNasri deleted the refine-not-found-main-directory-error branch February 22, 2023 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Respect localization for main directory (e.g., ~/Dokkumente)
3 participants