> * When updating a note, just use Note.LoadForeignNoteXml, and pass in
> the complete file contents. It is *probably* best to pass in
> ChangeType.OtherDataChanged
> * Recommend using NoteManager.FindByUri instead of doing your own loop
> (it does the same thing, but could be optimized in the future).
Cool, I was really unsure about the best way to do these things. A
big new API :).!
> * I'm curious about the 5 second delay. What's the point?
A file change is not usually a single operation. For example this is
what it looks like when Tomboy writes a note to disk. gedit is similar
but with a different file extension.
fd = open("{guid}.note.tmp", "rw")
write(fd, byte)
-> OnChange raised
write(fd, byte)
-> OnChange raised
write(fd, byte)
-> OnChange raised
write(fd, byte)
-> OnChange raised
flush(fd, byte)
-> OnChange raised (maybey, if there were bytes left)
close(fd, byte)
-> OnChange raised (this operating system specific, sometimes
metadata shows up as OnChange events)
delete("{guid}.note.tmp")
rename("{guid}.note.tmp", "rw")
The pattern of writes, renames, etc is dependent on the program
writing the file, the operating system, the size of buffers used, the
size of the note being written, FileSystemMonitor backend, the
filesystem (or network file system).
The best way to too watch for any kind of change and then wait for
things to settle down. Once its settled down the file has been
completely written.
All of this is based on real world experience.
The 5s was arbitrary. It could be 10s or 3s. Maybe not smaller that 2s.
> To ensure
> that Tomboy "wins" if a note queued to be saved also has its note file
> edited?
No. I compare the new note to the old note "if (data.Text !=
note.XmlContent) " and see if it changes. Unfortunately this patch
notices every change that Tomboy makes but then ignores it.
> * Shouldn't you filter on *.note? Or are you watching all files
> because of that tmp file stuff that happens when a note is saved?
See above. If I filtered on "*.note" all I would see is an OnDeleted
and OnRenamed event.
> * Please use the Logger class instead of Console.WriteLine
> * Some coding standards stuff, like needing spaces between methods and
> open parens, needing to put opening brace of method on its own line,
> etc
>
> Will have to try it out soon. :-)
>
> Sandy
>
>
_______________________________________________
Tomboy-list mailing list
Tomboy-list@...
http://lists.beatniksoftware.com/listinfo.cgi/tomboy-list-beatniksoftware.com