View Single Post
Old 08-03-2014, 05:59 AM   #1
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Request for opinions on setting up read info syncing

The problem that Library Addict reported has raised some serious issues with the "first time" process after read information lookup names are entered. I have a way to fix it robustly, but there are side effects. Your comments are welcome. And apologies for the length of this post.

Currently, the first connect after a read info lookup name is entered into CC is special. The rules for this special sync are:
  • If there is a value in CC, then that value is copied to calibre,
  • otherwise if there is a value in calibre, that value is copied to CC,
  • otherwise do nothing.
On any subsequent connect, the "normal" rules apply:
  • If the value in CC differs from the value last received by CC from calibre then the CC value is copied to calibre
  • otherwise if the currrent value in calibre is copied to CC

The intent of the special sync was to try to recover any information that the user might have entered into CC's read fields while ensuring that CC's fields were properly initialized. A side effect is that CC is not required to scan books because that will happen "naturally" as part of the metadata sync process.

The problem is that this special processing must be done on the first connect to every library, not simply the first connect to some library. If the special processing is not done then there is a high probability that when connecting to a subsequent library, books that come from that library will have their calibre read information erased. This is what happened to Library Addict.

There are two ways to fix this problem.

The first way is for CC to keep track of whether it has connected to a library after the read info lookup names have changed, and to use the special processing if it is the first connect. This method respects the intent expressed above, but can lead to strange behavior. For example, if a person connects to a backup library two months later then s/he probably doesn't expect to have CC's read information take precedence over what is in the backup library, which is what will happen under this scheme. It is also possible for a calibre library to change its unique ID (think backup/restore), which would trigger special processing on the next CC connect.

The second is to change CC so that when a lookup name is entered the "special processing" is done locally by CC. If the CC value is empty then the calibre value is copied to the CC value, otherwise the CC value is left alone. On the next connect to any library the "standard" sync scheme is used, which is possible because the CC values have been properly initialized. This second scheme has the advantage of having predictable behavior no matter how many libraries are used or whether the library changed identities. It simplifies the connection process because there is no longer any need for calibre to do the special processing. The downside is that a dreaded database upgrade would be required if the lookup names are changed. This is the same processing that currently happens when you enter a lookup name into the "Make groups ..." box.

My feeling is that the advantages of the second scheme are worth requiring the DB upgrade process. I am a fan of predictability. Changing one of the lookup names should be a rare process. The DB upgrade process runs at around 2 to 3 books per second, so people with smaller libraries won't pay much. Unfortunately, for large libraries the process will take significant time.

Comments?
chaley is offline   Reply With Quote