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

Enhanced backup restore dialog #2961

Open
jonasstein opened this issue Jul 3, 2017 · 32 comments
Open

Enhanced backup restore dialog #2961

jonasstein opened this issue Jul 3, 2017 · 32 comments

Comments

@jonasstein
Copy link

selection_311

This warning should tell the user exactly what the consequences of yes/no are. Some users want to create a backup or investigate the files manually, before answering the question.

A few ideas how to help the user:

  • name the backup file literature.bib.sav for example, so that the user can look for it
  • will recover overwrite the .bib file?
  • will the .bib.sav be deleted, if NO is selected?
  • what is the difference between the two files? size/date/number of entries/perhaps suggest the user to run a diff tool like diff or meld
  • if the user can not answer this question now, give a chance to cancel.
  • allow to ignore the question, if the user wants to start jabref and work on another file, but can not answer the recover question now.
@koppor
Copy link
Member

koppor commented Jul 3, 2017 via email

@koppor
Copy link
Member

koppor commented Jul 7, 2017

Refs JabRef#149

@notuntoward
Copy link

I'll just add that I never used to see this popup but now see it all the time, whether or not I've saved the .bib file before exiting jabref.

@j0hannes
Copy link

j0hannes commented Dec 8, 2017

Me too, almost every time I open JabRef the popup appears.

I'm usually clicking yes assuming that the backup file is a newer version of the bib file. I'm a right?

@chrisrapson
Copy link

I've noticed that the backup files (.bib.bak or .bib.sav) are often NOT newer than the .bib file. So I now open up my file manager, navigate to the folder and check the modification times before making my decision.

There are times when it's good to have a backup that's older than the .bib file, for example when I delete an entry by accident and want to recover it. But most of the time I want the most recent changes. So maybe a button that can expand the window with "details" like modification times would be useful. The window expansion could include the answers to jonasstein's other questions. Going further, a diff would be the ultimate way of knowing which file I want to use.

@koppor
Copy link
Member

koppor commented Jun 5, 2018 via email

@chrisrapson
Copy link

chrisrapson commented Jun 5, 2018

I've got a bit much on for the next month or so, but if this is still open after that I might have a look at it. (I won't mind if someone jumps in and takes care of it before then!)

Quick related question: what is the reason for having a backup file and an autosave file?

@koppor
Copy link
Member

koppor commented Jun 6, 2018

The backup file is a relict from old JabRef times. The bak file was created before saving the database. The reason was to be be able to recover from failed saves. In 2016 we decided to keep this feature. However, none of the users reported broken bibliography files, so the bak feature can be removed when working on this. - We would be really happy if you found time this summer. Most of our developers are also online at https://gitter.im/JabRef/jabref so that we can answer questions there.

@github-actions github-actions bot added the status: stale Issues marked by a bot as "stale". All issues need to be investigated manually. label Dec 31, 2020
@pat-richter
Copy link

This issue still persists with JabRef 5.3. I get annoyed/irritated quite often, but still can't detect the issue behind.

A simple solution would be to add some more information (modification date), as already suggested.
Instead, I would like to see a third button.

Button 1: Use current file
Button 2: Use backup file
Button 3: Compare files

The third button should open the dialog which is also shown, when the file has been changed by an external program.

With this solution one could

  • easily see whats going on (no more guessing) and then choose the right file
  • also keep only some changes, e.g. when the last edit of the library file has lead to some confusion¹

¹ I've had some times, when I copyied and pasted the bibtex code, without changing the bibtex key. This has led to broken bib file. I currently have my bib in a dropbox. But also in a git repo (which allows my to compare to a previous version easily). I would like to dispense on that additional "backup" step.

@koppor koppor removed the status: stale Issues marked by a bot as "stale". All issues need to be investigated manually. label Jul 14, 2021
@koppor koppor reopened this Jul 14, 2021
@JabRef JabRef deleted a comment from github-actions bot Apr 11, 2022
@koppor koppor mentioned this issue Aug 13, 2022
6 tasks
@ThiloteE
Copy link
Member

f7648e8 introduced multiple backup files (10 to be exact), but the problem here is still valid:

  • Give user more information about these multiple backup files, so that
  • they can choose the correct one to import,
  • or dismiss importing altogether.

@koppor koppor moved this to Normal priority in JabRef UI Improvements Nov 11, 2022
@koppor
Copy link
Member

koppor commented Mar 16, 2023

The current dialog reads as follows:

image

@koppor koppor changed the title A backup was found: Tell the user what does recover really mean? Enhanced backup restore dialog Mar 16, 2023
@yenniejunvu
Copy link
Contributor

Hi! Is this issue still available? If so, can I try it?

@ThiloteE
Copy link
Member

@gnandini156

To trigger the popup:

  1. open/create a library with JabRef
  2. save said library
  3. Change something in the library, e.g. adding a comment or adding a new entry.
  4. Wait ~ 20 seconds for a backup to be created
  5. Close JabRef and the library WITHOUT saving.
  6. Open JabRef and said library again
  7. Now the popup should trigger.

@ThiloteE
Copy link
Member

See also https://docs.jabref.org/advanced/autosave for where backups are stored

@KotalaRadhika
Copy link

KotalaRadhika commented Feb 22, 2024

Hi @jonasstein @koppor

Could you please elaborate what to be fixed here?

i'm getting below popup
bug

Also all 3 buttons are working fine.

@koppor
Copy link
Member

koppor commented Feb 22, 2024

@KotalaRadhika Good to see that you could bring up the dialog. Sadly, you did not show what happens at "Review backup"

Now, let's walk through the original posters steps.

This warning should tell the user exactly what the consequences of yes/no are. Some users want to create a backup or investigate the files manually, before answering the question.

This is a general remark. Fortunately, the reporter refined it.

A few ideas how to help the user:

Heading for the following list. OK, let's read on.

name the backup file literature.bib.sav for example, so that the user can look for it

This is already done. We see it in blue in the dialog.

will recover overwrite the .bib file?

By the button "Review backup", the next step should be clear

will the .bib.sav be deleted, if NO is selected?

It should also be clear with the buttons. Hopefully

what is the difference between the two files? size/date/number of entries/perhaps suggest the user to run a diff tool like diff or meld

This should be in the dialog.

  • A table
Property Current file Backup file
Name bug_reproduce.bib ...07.bak
Size 100kb 0kb
Date 2024-02-22 10:05 2024-02-21 23:49
Number of entries 100 95
Changes - removed: 7, added: 2, modified: 3

That information should be put into the dialog. I think, this is possible using the Bibdatabase Diff. -- The numbers for "Number of entries" and "Changes" should be calculated in a Background Task, because for large files, this could take time.

  • Moreover, launching directly an external diff tool would be great.
  1. New button "External diff" (that launches the diff tool)
  2. Let the tool be configured at "External programs"

image

No need for place holders. Pass first the backup file and then the .bib file.

The default tool is git diff --no-index (see https://stackoverflow.com/a/17194704/873282)

if the user can not answer this question now, give a chance to cancel.

I think, with "Ignore Backup" this is fulfilled.

allow to ignore the question, if the user wants to start jabref and work on another file, but can not answer the recover question now.

Also done with "Ignore Backup"


Hope, this helps

In general, the issue refs This somehow refs #10853.

.

@ThiloteE ThiloteE moved this from Reserved to Free to take in Candidates for University Projects May 20, 2024
@koppor
Copy link
Member

koppor commented Sep 17, 2024

Even more refined: #11454 (comment)

@koppor koppor added this to the 6.0-beta milestone Sep 17, 2024
@koppor
Copy link
Member

koppor commented Sep 24, 2024

Technical hint: Use git and appdirs.

  • Option .bak file (even with git-bundle): Not good, because if used on Dropbox, conflicts may arise.
  • Option git allows for "removing" intermediate backups
  • Option rcs: There is no good Java support - and squashing revisions is not supported.

@koppor koppor removed the FirstTimeCodeContribution Triggers GitHub Greeter Workflow label Sep 25, 2024
@khola22
Copy link

khola22 commented Oct 14, 2024

Hello, we are the group of students who would like to work on this issue within the framework of our school project. We are commenting so that you assign the issu to us. Thank you !

I note that the group is composed of :
@khola22 me
@Daren42
@Gillan0
@safaa0812
@ilias-lwa3r
@nawalchahboune

@koppor
Copy link
Member

koppor commented Oct 14, 2024

@khola22 I can only assign students commenting on this PR. I think, for formality it is OK to assign one person of your group?

@koppor koppor added the FirstTimeCodeContribution Triggers GitHub Greeter Workflow label Oct 14, 2024
Copy link
Contributor

Welcome to the vibrant world of open-source development with JabRef!

Newcomers, we're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

In case you encounter failing tests during development, please check our developer FAQs!

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

Happy coding! 🚀

@JabRef JabRef deleted a comment from github-actions bot Oct 14, 2024
@koppor
Copy link
Member

koppor commented Oct 14, 2024

@khola22 I am so happy that a group of students chose this task. Please start from #11454 (comment). That should be enough for a requirements document. Then, you can add a directory for backups to org.jabref.logic.util.Directories. Then, you can add the use of git to handle files in this directory. You will probably rewrite org.jabref.gui.autosaveandbackup.BackupManager completely.

You could even craft "real" a requirement document. See https://github.com/JabRef/jabref/blob/main/docs/requirements/index.md for hints.

@koppor koppor moved this from Free to take to Assigned in Candidates for University Projects Oct 14, 2024
@nawalchahboune
Copy link

@koppor

Hello!!
We are the group of students working on improving the version management of libraries in JabRef using JGit. We have implemented a feature that allows modifications to be saved as commits while giving users the ability to restore a previous version.

We have evaluated two possible approaches for version restoration:

first approach

Moving the HEAD to the restored version: This method shifts the HEAD to the selected version, making it the latest commit. However, this approach rewrites the commit history, preventing the user from restoring intermediate versions.

second approach

Rewriting the current version with the content of the restored version: This method preserves the commit structure by copying the content of the restored version to the current version. This way, the entire history remains intact, and new commits naturally follow the initial HEAD.

We would like to get your input on which approach you consider most appropriate for JabRef, taking into account flexibility and user experience.

@nawalchahboune me
@khola22
@Daren42
@Gillan0
@safaa0812
@ilias-lwa3r

@koppor
Copy link
Member

koppor commented Nov 7, 2024

while giving users the ability to restore a previous version.

I don't know if this was requested. (I was in the wrong context)

Please do not re-invent git concepts.

Never ever rewrite history!!!

In short: Restore the file system contents. Then do a commit.

Alternatives:

You know that going back to a previous version is equal to a "git checkout commitid". And then git warns you that one works in a detached head. Then, one could work on a new branch.

One could also reset the current branch to that commit. Then, the remote branch will diverge and will need more handling.

@khola22
Copy link

khola22 commented Nov 26, 2024

Hello @koppor !
We have new codes implemented for the new BackupManagerGit class and also for the UI, we are trying now to write tests so we can be sure that it is working / correct and enhance our code.
We want to have some insights on how to lead the tests for the BackupManagerGit class because it seems a bit complicated, given the whole structure of Jabref and how BackupManager is used in many other classes ...
We want also to be sure that it s okay to have the backup manager and the UI codes merged, or should we keep them seperated.
Thank you !

@koppor
Copy link
Member

koppor commented Nov 27, 2024

We have new codes implemented for the new BackupManagerGit class and also for the UI,

Nice! Where is the PR? 😅

We want also to be sure that it s okay to have the backup manager and the UI codes merged, or should we keep them seperated.

None of us can judge without seeing the code.

In general, think of JabRef also as CLI tool without any UI components. Then, JabRef should also work. Thus, the UI should be "dumb" and most logic should not be part of the UI...

@khola22
Copy link

khola22 commented Dec 1, 2024

Hello @koppor ,

We apologize for the delayed response. We've been working on validating our code and relied heavily on loggers to debug (apologies for the clutter). Here's an update: backups are now tracked in a Git repository under jabref/backups, where .bib files are copied every 19 seconds to maintain a Git history. However, change detection currently occurs only when .bib files are overwritten, which is triggered by actions like Save, Save All, or the save prompt during exit. Our reliance on listeners for tracking edits imposes strict conditions, which limits dynamic change detection and leads to two main issues:
1/ It is not possible to autosave changes without manually clicking Save or Save All.
2/ Recent changes are not recorded if the application closes unexpectedly.

The UI is mostly complete, but we are encountering challenges with the checkout functionality. We are uncertain if our current approach using JGit to revert commits is correct. On the positive side, commit retrieval, discarding changes, saving, and committing all work as intended. Since we replaced the BackupManager with a BackupManagerGit class, we adapted other components to integrate this new system.

Being new to contributing on GitHub, we are unsure whether we should open a pull request (PR) to share our incomplete work for feedback or if there is another recommended process. Your guidance would be greatly appreciated!

P.S.: We did not modify classes like CoarseChangeFilter for autosaving functionality.

Best regards,
The team

@koppor
Copy link
Member

koppor commented Dec 1, 2024

@khola22 Thank you for the update. Please create a pull request. This enables us to investigate.

@khola22 khola22 mentioned this issue Dec 2, 2024
7 tasks
@khola22
Copy link

khola22 commented Dec 2, 2024

@koppor the pull request is done !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Assigned
Status: Normal priority
Development

No branches or pull requests