After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 665679 - Sync fails with "New Note Template already exists"
Sync fails with "New Note Template already exists"
Status: RESOLVED NOTGNOME
Product: tomboy
Classification: Applications
Component: General
1.8.x
Other Linux
: Normal normal
: ---
Assigned To: Aaron D Borden
Tomboy Maintainers
gnome[moved-to-github]
Depends on:
Blocks:
 
 
Reported: 2011-12-06 17:10 UTC by Cedric Bosdonnat
Modified: 2017-07-31 12:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch fixing the issue (based on 1.8.0 tarball) (2.86 KB, patch)
2011-12-06 17:10 UTC, Cedric Bosdonnat
none Details | Review
Updated patch, there was a missing bit in the previous one. (3.35 KB, patch)
2011-12-07 09:46 UTC, Cedric Bosdonnat
rejected Details | Review
Fix syncing with template notes (4.09 KB, patch)
2011-12-12 01:59 UTC, Aaron D Borden
none Details | Review
Fix sync with template notes (4.19 KB, patch)
2011-12-12 02:21 UTC, Aaron D Borden
none Details | Review
Exception log after using patch (1.56 KB, text/x-log)
2011-12-14 23:39 UTC, Jared Jennings
  Details

Description Cedric Bosdonnat 2011-12-06 17:10:23 UTC
Created attachment 202921 [details] [review]
Patch fixing the issue (based on 1.8.0 tarball)

During synchronization with a local folder with a fresh tomboy instance, I have an exception raised.

After some debugging, it happens that the template note is removed when importing the new one, but it's recreated right after in the CreateNewNote() method. The attached patch, adds a flag indicating if we are in a synchronization or not to avoid re-creating the default template note in that case.
Comment 1 Cedric Bosdonnat 2011-12-07 09:46:04 UTC
Created attachment 202971 [details] [review]
Updated patch, there was a missing bit in the previous one.
Comment 2 Jared Jennings 2011-12-07 21:14:40 UTC
Thanks for creating a patch, but I have a question. More from ignorance than anything.

Why do we need this flag? Would it be better if Tomboy checked to see if the Template note already existed? Otherwise this seems like we could be introducing another bug with somekind of state issue (like what we have now)
Comment 3 Cedric Bosdonnat 2011-12-08 08:13:08 UTC
(In reply to comment #2)
> Thanks for creating a patch, but I have a question. More from ignorance than
> anything.
> 
> Why do we need this flag? Would it be better if Tomboy checked to see if the
> Template note already existed? Otherwise this seems like we could be
> introducing another bug with somekind of state issue (like what we have now)

The problem is that we fall into the case where the code [0] checks for an existing auto-generated note with the same title like the Template notes and removes it. But CreateNoteInMainThread() a few lines below recreates the Template note if that one isn't existing, before importing the content of the note to synchronize [1].

The case I've fallen into is that it tries to sync the Template note and finds one. It then deletes it, recreate it automatically and tries to import the content of the Template note from the synced note... which now breaks due to that auto-regeneration.

I know that using a flag isn't a beautiful hack, but do we have any other way to tell the NoteManager not to try to create the auto-generated notes during a synchronization?

[0] http://git.gnome.org/browse/tomboy/tree/Tomboy/Synchronization/SyncManager.cs#n487
[1] http://git.gnome.org/browse/tomboy/tree/Tomboy/NoteManager.cs#n536
Comment 4 Jared Jennings 2011-12-08 21:32:41 UTC
I went through the code and can't really come up with a better way other than ripping a lot of code.

I applied the patch to my build and will run it awhile.
Comment 5 Aaron D Borden 2011-12-12 01:56:30 UTC
Review of attachment 202971 [details] [review]:

Thanks for the patch! However this fixes only part of the issue. Theres a few other issues I found related to syncing template notes and have been working on them, I didn't realize I didn't have a bug to track this (sorry for that).

Also, instead of changing the signature of CreateWithGuid so you then have to explicitly specify to use the template or not, I think it just makes more sense for CreateWithGuid to create a note with empty content and avoid using the template at all. Presumably if you're creating with a guid, the note already exists in some sense and shouldn't be based on a template at all.
Comment 6 Aaron D Borden 2011-12-12 01:59:25 UTC
Created attachment 203227 [details] [review]
Fix syncing with template notes

Make template delete/re-create atomic on the main thread.
Make CreateWithGuid create an empty note instead of using the template.
Comment 7 Aaron D Borden 2011-12-12 02:21:17 UTC
Created attachment 203228 [details] [review]
Fix sync with template notes

Oops, forgot to change the template buffer text as well.
Comment 8 Jared Jennings 2011-12-14 23:38:37 UTC
Aaron,
I added your patch and set my sync schedule to 10 minutes. I sync with one.ubuntu and I got a failure.

Attaching tomboy.log
Comment 9 Jared Jennings 2011-12-14 23:39:15 UTC
Created attachment 203526 [details]
Exception log after using patch
Comment 10 Aaron D Borden 2011-12-15 07:08:56 UTC
(In reply to comment #9)
> Created an attachment (id=203526) [details]
> Exception log after using patch

Thanks for trying it out. This is a thread sync issue where the sync thread is calling note.Save. It should be delegating it to the main thread though.
Comment 11 Jared Jennings 2012-04-18 14:00:56 UTC
Aaron, Do you have any latest code on this? We never committed this to master right?
Comment 12 André Klapper 2017-07-31 12:47:58 UTC
The Tomboy team has moved from GNOME Bugzilla to GitHub for bug reports and feature requests: 
      https://github.com/tomboy-notes/tomboy/issues/
Closing this report as NOTGNOME as part of Bugzilla Housekeeping (bug 781054) to keep tasks in one place. Please feel free to transfer this task to GitHub if this task is still valid in a recent Tomboy version. 
We are sorry for the inconvenience.