Continue the title with "Or we need to modify TWC core substantially?"
I used savetiddlers <https://github.com/buggyj/savetiddlers> (only version 0.6 worked on my FireFox with macOS while 0.8 simply didn't) to save my TWC until FireFox was automatically updated to 68.0.1 last week. I learned all the code of savetiddlers and the saving mechanism of TWC while I was trying to fix some problems in savetiddlers. Although I'm not 100% sure, I'm suspicious about the asynchronous philosophy (as Yakov mentioned several times), at least for the current implementation of TWC core. To my understanding, saveMain() in TWC will set the dirty flag to false after saveFile() returns. Consider you are working a big TWC file, and saving take several seconds to accomplish. Between subsequent 2 savings, something will happen this way: 1. You finish editing a tiddler A and click the done button. A save message will send to a saver. 2. Because the saving operation is asynchronous, saveFile() immediately returns and then the dirty flag is set to false. 3. The saver is downloading the new TWC file with the update tiddler A. 4. Before the new TWC file downloading finishes, you edit another tiddler B and finish editing it and click the done button. The TWC core will load the original TWC file from the local file system *WITHOUT* the updated tiddler A, and send another saving message to the saver. Because in step 2 the dirty flag is set to false, this time the updated content contains only updated tiddler B and the *ORIGINAL* tidder A (tiddler A is thought to be already up-to-date). 5. The saver makes a new download operation where the TWC file to be saved contains only the original content with the updated tiddler B. 6. A few seconds later, the first downloading finishes, now the local TWC file contains original content and updated tiddler A. 7. Another few seconds later, the second downloading finishes, now the local TWC file contains original content and updated tiddler B. 8. Note that ultimately you lose your work on tiddler A. To be honest, I haven't done any test to check whether the situation above will happen. But anyway, I think asynchronous saving needs more thorough thinking. To enable asynchronous loading and saving, I think we need to modify TWC core so that only if a "save-successful" message is received then the dirty flag could be set to false. -- You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/52387b36-3071-4b5a-b22b-a29be398f0dd%40googlegroups.com.
