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

Avoid update notes unnecessarilly and report note conflict #358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jinuxstyle
Copy link

Currently, gnsync uses mtime of the local and server notes to
decide whether to update server or local notes. The problem is
that by comparing the mtimes, gnsync can only know which note
is newer than the other but not know whether they have been
changed since the last sync, neither know whether they have
conflicts or not. So it would update notes even they have not
been changed since last sync, and if both the server and local
copy of a note have been changed, it always overwrite the server
note, causing the changes made on the side side lost.

This patch saves the mtimes for both server and local notes to
a file and it will be used as a guideline for future sync.
By comparing current mtimes of a note with the saved mtimes,
gnsync could know exactly whether the note on server was changed
or the note was changed locally or the note on both side were
changed. Thus, it can always make right decision to sync notes.

If both local and server notes have been changed since last sync,
gnsync will report the potential conflicts and suggest user to do
merge. Upon conflicts, gnsync will download the server note and
save it locally as a file prefixed with a dot and postfixed with
a .rej extension. User could check the difference and do merge
manually. After merged, user could sync the conflicting notebook
again with a newly introduced option --merged to get the notebook
in sync.

Currently, gnsync uses mtime of the local and server notes to
decide whether to update server or local notes. The problem is
that by comparing the mtimes, gnsync can only know which note
is newer than the other but not know whether they have been
changed since the last sync, neither know whether they have
conflicts or not. So it would update notes that have not been
changed since the last sync unnecessarily, and it always
overrite notes on server with the local notes if the notes
on both side were changed.

This patch saves the mtimes for both server and local notes to
a file and it will be used as a guideline for future sync.
By comparing current mtimes of a note with the saved mtimes,
gnsync could know exactly whether the note on server was changed
or the note was changed locally or the note on both side were
changed. Thus, it can always make right decision to sync notes.

If both local and server notes have been changed since last sync,
gnsync will report the potential conflicts and suggest user to do
merge. Upon conflicts, gnsync will download the server note and
save it locally as a file prefixed with a dot and postfixed with
a .rej extension. User could check the difference and do merge
manually. After merged, user could sync the conflicting notebook
again with a newly introduced option --merged to get the notebook
in sync.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant