DavidMStraub / gramps-web-sync

Development version of a Gramps addon to synchronize Gramps Web with Gramps Desktop
GNU General Public License v3.0
12 stars 2 forks source link

sync direction should be configurable #12

Closed ondrno closed 1 year ago

ondrno commented 1 year ago

Environment: grampsweb 0.17, websync plugin (as of 08.12.2022)

Maybe a bug, more probably a feature request.

Steps to reproduce: 1) start with an empty family tree in grampsweb 2) do the websync in gramps 3) in final confirmation the plugin will show:

Local changes (none) Remote Changes deleted (1140)

Obviously, that is the currently implemented behaviour. However, it could also work the other way around, i.e. local changes (1140), remote changes (none)

Thus, it would be great if the sync direction could be defined. Local -> web, web -> local, web <-> local

DavidMStraub commented 1 year ago

In principle yes, but this is hugely more complicated in general. If a user wants to merge two trees which have many differences and the user wants to pick for each object the sync direction, they should use the Import Merge Tool that was created exactly for this purpose. The sync addon is not for merging, only for 1:1 syncing.

The case you describe is a special case however: if one tree is completely empty, the tool could offer to copy the non-empty one, as deleting everything is probably never what the user wants.

mvroosmalen1970 commented 1 year ago

Hi,

I've successfully filled a empty database using the sync tool. However, after making some edit online and sync and making new edit in gramps (linux). The new changes were recognized as deleted, similar to the case above. I would appreciate the option to select the sync direction to overcome deletion, as in my case I'm 100% sure no records were edited in the web.

Hope this helps to create the feature ;-). Not sure why the tool sees the changes as deleted, as they were created and not changed in the web.

DavidMStraub commented 1 year ago

Hi,

what you describe sounds like a bug, so let's try to find out want went wrong.

I understand the wish to configure the sync direction, but this is a Pandora's box that I do not want to open - this tool should be more like Dropbox, which is also not asking you about the sync direction, if you know what I mean.

Can you please describe exactly in which order you changed and synced?

  1. Edit online
  2. Sync: what happened?
  3. Edit on desktop: which objects? The same ones or different ones?
  4. Sync: what happened?
mvroosmalen1970 commented 1 year ago

image Edit online Sync: what happened? ===> OK no issues, changes imported. Edit on desktop: which objects? The same ones or different ones? same and different Sync: what happened? see screenshot

Can I share a log? how?

mvroosmalen1970 commented 1 year ago

This is the last record in the web database: image so all flagged as deleted are new in the desktop version

The date flag of last records in the databases are: Desktop: 1677705002 web: 1677612510

so that seems correct and shows recent updates of the desktop data.

DavidMStraub commented 1 year ago

Ok, last piece of information needed, can you please check ~/.gramps/gramps51/plugins/webapisync.ini and post the value of timestamp in the credentials section?

DavidMStraub commented 1 year ago

Some background: since currently there is no database history, "added" and "deleted" are based on timestamps:

  1. A "last synced state" timestamp T is determined
  2. If an object is present in database A and absent in database B, it is considered
    • deleted in B if the last change timestamp of the object in A is before T
    • added in A if the last change timestamp of the object in A is after T

T is determined in the following way:

The timestamp in the config file is set at the moment of time when a sync completes, either with a successful synchronization or after finding both databases are equal.

In your example, I0292-I0305 are shown as deleted remotely, which means that T is larger (later) than the last change timestamp of these objects on desktop. There are two possibilities here:

cdhorn commented 1 year ago

Time not in sync between the two machines if they are not both running NTP?

mvroosmalen1970 commented 1 year ago

Ok, last piece of information needed, can you please check ~/.gramps/gramps51/plugins/webapisync.ini and post the value of timestamp in the credentials section?

timestamp=1677702356.40323

mvroosmalen1970 commented 1 year ago

Time not in sync between the two machines if they are not both running NTP?

both have the correct (same time) being in sync with NTP pools

DavidMStraub commented 1 year ago

So thats 1. March 2023 20:25:56 UTC for the last successful sync. Does that match? That would imply that I0292-I0305 have a last changed timestamp before that. Can you confirm? Can you share the change timestamps of I0292 and I0305?

mvroosmalen1970 commented 1 year ago

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

I0294 0 -1 -1 1677699125
I0295 1 -1 -1 1677699404
I0296 0 -1 -1 1677699404
I0297 0 -1 0 1677701085
I0298 0 1 0 1677701085
I0299 0 -1 0 1677701085
I0300 0 -1 0 1677701085
I0301 0 -1 0 1677701085
I0302 0 -1 0 1677701085
I0303 0 -1 0 1677701085
I0304 0 -1 0 1677701085
I0305 0 1 0 1677701085

1677699404

1677699404 1677701085 1677701085 1677701085 1677701085 1677701085 1677701085 1677701085 1677701085 1677701085

DavidMStraub commented 1 year ago

Right, so their timestamp is 20-50 minutes before the last successful sync. But both timestamps refer to your desktop, so clock sync can't be an issue.

Looking at the source code, the sync addon uses datetime.now().timestamp(), while Gramps DBAPI uses time.time(). Both are timezone independent, so that can't be an issue as well.

Can you tell whether creating the objects between 19:30 and 20:10 UTC or successfully syncing at 20:25 UTC is correct?

mvroosmalen1970 commented 1 year ago

Before I added the new records I've sync successfully with the web, next I completed the edits but failed sync after that (showed as deleted)

DavidMStraub commented 1 year ago

It's really puzzling, I don't see how this could happen.

A workaround for the moment would be to delete the timestamp in the config file.

mvroosmalen1970 commented 1 year ago

OK thanks