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

Entry is missing after sublibrary is generated from aux file #6405

Closed
1 task done
xx256xx opened this issue May 3, 2020 · 6 comments · Fixed by #6746
Closed
1 task done

Entry is missing after sublibrary is generated from aux file #6405

xx256xx opened this issue May 3, 2020 · 6 comments · Fixed by #6746
Assignees
Labels
bug Confirmed bugs or reports that are very likely to be bugs export / save
Milestone

Comments

@xx256xx
Copy link

xx256xx commented May 3, 2020

JabRef version 5.0 on Windows 10

Steps to reproduce the behavior:

  1. The test package is available at https://github.com/xx256xx/test, including a tex file, the original bib my.bib, a aux file report.aux.
  2. I attempt to generate a sub library using report.aux from my.bib.
  3. In Jabref window, the sub library succeeds to generate the sub library. See jabref
  4. However, this entry is not found in the saved bib file ( you can check it at my repo, named by sub.bib). jabref2
  5. If I fill in the "date" field and save again, the resultant bib is correct.

No log available.

Log File
Paste an excerpt of your log file here
@xx256xx
Copy link
Author

xx256xx commented May 3, 2020

The zip file is upload a test repo for the security purpose. You can find all the files at https://github.com/xx256xx/test. Run test.bat to quickly reproduce the issue.

@Siedlerchr Siedlerchr added the bug Confirmed bugs or reports that are very likely to be bugs label May 8, 2020
@Siedlerchr
Copy link
Member

I could confirm this issue. You are right, for some reason the entry gets deleted.
When I do this manually in JabRef and try to save the new library, I get the "Review changes" dialog which states that the entry got deleted.

grafik

@Siedlerchr Siedlerchr added this to the v5.1 milestone May 9, 2020
@xx256xx xx256xx changed the title missing entry after generate sublibrary from aux file Entry is missing after sublibrary is generated from aux file Jul 14, 2020
@Siedlerchr
Copy link
Member

Okay, this seems to be a bit weird. I debugged a bit further and found out that the problem lies in the following lines when saving:

public void write(BibEntry entry, Writer out, BibDatabaseMode bibDatabaseMode, Boolean reformat) throws IOException {
// if the entry has not been modified, write it as it was
if (!reformat && !entry.hasChanged()) {
out.write(entry.getParsedSerialization());
return;

The second entry, the one with "lichman" has the flag changed = false and the getParsedSerialization() returns an empty string.
I don't know that much about the internal stuff and no idea when this flag or the serialization should be set
@koppor @tobiasdiez Any idea? I only noticed that the AuxParser "clones" the BibEntry before inserting into the database. But no idea if this affects the serialization

@koppor
Copy link
Member

koppor commented Aug 7, 2020

The code at hand ensures that entries are only written in JabRefs cool new "layout" if there is a change. This was a year-long discussion before you joined JabRef. - The idea is that JabRef stores the characters as they are read when reading the file. It writes out the characters as is when writing - except the user has changed something. - This is what the if condition states.

Now to the issue: I think, the code creating entries from the aux file just does not set the reformat flag correctly. I could also argue that we need a BibEntry clone method also cloning the serialization. - I did not look into the code how the aux part generates BibEntries. That the problem is hidden there, I am sure.

Siedlerchr added a commit that referenced this issue Aug 7, 2020
Set changed flag on clone also for Misc entry type, because otherwise it equals the default entry type and no change is triggered which results in the entry not beeing written to the database on save
Fixes  #6405

Simplify gui code
@Siedlerchr
Copy link
Member

@koppor Thanks for the explanation. That was indeed very helpful and let me to the root issue, that the clone method does not set the changed flag when the entry type is Misc and therefore equals the default entry type.

Siedlerchr added a commit that referenced this issue Aug 18, 2020
* Fix entry gets deleted after aux import

Set changed flag on clone also for Misc entry type, because otherwise it equals the default entry type and no change is triggered which results in the entry not beeing written to the database on save
Fixes  #6405

Simplify gui code

* add changelog

* fix checkstyle shit

* copy serialization on clone

* Update CHANGELOG.md

Co-authored-by: Tobias Diez <tobiasdiez@gmx.de>

* Cosmetic change

* Fix clone

* Mark each entry changed to trigger a "proper" write by JabRef

Co-authored-by: Tobias Diez <tobiasdiez@gmx.de>
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
@Siedlerchr
Copy link
Member

@xx256xx This issue is now fixed in the latest master

We would like to ask you to use a development build from https://builds.jabref.org/master and report back if it works for you. Please remember to make a backup of your library before trying-out this version.

@koppor koppor moved this to Done in Prioritization Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs export / save
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants