Tiddloid icon indicating copy to clipboard operation
Tiddloid copied to clipboard

Saving tiddlywiki does not overwrite the whole file

Open Dialga opened this issue 3 years ago • 19 comments

Screenshot_20210804-230407_Tiddloid

The last 30 lines in my tiddlywiki file:

/////////////////////////// Autoboot in the browser

if($tw.browser && !$tw.boot.suppressBoot) {
	$tw.boot.boot();
}

return $tw;

});

if(typeof(exports) !== "undefined") {
	exports.TiddlyWiki = _boot;
} else {
	_boot(window.$tw);
}
</script>
</div>
<!--~~ Raw markup for the bottom of the body section ~~-->

</body>
</html>
lyWiki = _boot;
} else {
	_boot(window.$tw);
}
</script>
</div>
<!--~~ Raw markup for the bottom of the body section ~~-->

</body>
</html>

As you can see some ten lines from the old tiddlywiki file remain in the newly saved file. This happens sometimes when the to be saved tiddlywiki becomes smaller than the original. Perhaps the old file should be truncated first before being overwritten?

Dialga avatar Aug 04 '21 11:08 Dialga

I get something similar occurring with this code left over in the main window:

html> yptedTiddlers(function() { // Startup $tw.boot.startup({callback: callback}); }); }; /////////////////////////// Autoboot in the browser if($tw.browser && !$tw.boot.suppressBoot) { $tw.boot.boot(); } return $tw; }); if(typeof(exports) !== "undefined") { exports.TiddlyWiki = _boot; } else { _boot(window.$tw); }

This has happened after moving phones from Android 8 to Android 11. Will this cause any problems?

mikjsmith avatar Aug 28 '21 08:08 mikjsmith

P.S. Ive switched back to AndTidWiki which currently seems to be working OK

I get something similar occurring with this code left over in the main window:

html> yptedTiddlers(function() { // Startup $tw.boot.startup({callback: callback}); }); }; /////////////////////////// Autoboot in the browser if($tw.browser && !$tw.boot.suppressBoot) { $tw.boot.boot(); } return $tw; }); if(typeof(exports) !== "undefined") { exports.TiddlyWiki = _boot; } else { _boot(window.$tw); }

This has happened after moving phones from Android 8 to Android 11. Will this cause any problems?

mikjsmith avatar Aug 28 '21 11:08 mikjsmith

I have no idea :( In theory it will prompt a failure if the file is corrupted. And nothing's wrong on my non-android-11 AVDs and my own phone (8.1). I hav asked a question about this on stackoverflow. Good luck to me :(

donmor avatar Aug 28 '21 11:08 donmor

P.S. Ive switched back to AndTidWiki which currently seems to be working OK

I get something similar occurring with this code left over in the main window:

html> yptedTiddlers(function() { // Startup $tw.boot.startup({callback: callback}); }); }; /////////////////////////// Autoboot in the browser if($tw.browser && !$tw.boot.suppressBoot) { $tw.boot.boot(); } return $tw; }); if(typeof(exports) !== "undefined") { exports.TiddlyWiki = _boot; } else { _boot(window.$tw); }

This has happened after moving phones from Android 8 to Android 11. Will this cause any problems?

BTW it seems that legacy mode is still working. Maybe it's time to find an old file manager... (:з」∠)

donmor avatar Aug 28 '21 11:08 donmor

As this is my "live" TW I was concerned it might corrupt it. There is no evidence that this has happened, other than the code in the main window, but I wanted to be cautious.

What is legacy mode?

mikjsmith avatar Aug 28 '21 14:08 mikjsmith

The legacy mode uses file:// uris, which is being deprecated by google ,requiring storage permissions. This is to keep compatibility to 1.x wikis. To add a new wiki in legacy mode, you need to find an old file manager(targeting android version <4.4), which uses file:// to open files. Then you can choose Tiddloid here to add the file.

donmor avatar Aug 28 '21 14:08 donmor

BTW andtidwiki also uses file://, which is used with java file api, aged but relyable.

donmor avatar Aug 28 '21 14:08 donmor

Ah, I understand. As AndTidWiki has a default directory I was able to copy my TW there and then open it which solved the problem

mikjsmith avatar Aug 29 '21 15:08 mikjsmith

Are you using cloud services that support WebDAV? Now you can checkout the latest 2.2.0-pre version here (This is a pre-release with a debug package)

donmor avatar Feb 05 '22 07:02 donmor

I've been using rclone serve webdav . on my pc, but I'll try your prerelease later.

Dialga avatar Feb 05 '22 07:02 Dialga

Debug package does not install: "App not installed as package appears to be invalid."

Dialga avatar Mar 17 '22 10:03 Dialga

Screenshot_2022-04-18-18-32-20-937_top.donmor.tiddloid.jpg

我今天也遇到这个了,不过笔记还是可以正常使用 ,对我同步回桌面板也没啥影响

linonetwo avatar Apr 18 '22 10:04 linonetwo

Screenshot_20220501-115510.png

Very large amount of code shown after saving a brand new wiki after only adding two tiddlers.

Has no impact on usability but is concerning

nettybun avatar May 01 '22 18:05 nettybun

Applied some tricks to the app. Now it'll decode the file ahead-of-time if on Android 11+ and using SAF, and try to remove all contents behind the first </html>\n, which is rendered as some kinds of codes in viewer. The actual file won't be shrinked though, until the file become larger than before.

donmor avatar May 04 '22 07:05 donmor

Ok where is the commit?

Dialga avatar May 04 '22 08:05 Dialga

Not pushed yet XD 16516551613116489800846240001639

donmor avatar May 04 '22 09:05 donmor

Update: Android 10 is also affected. My Android 10 AVD is wonky and missing random characters on any interfaces so I didn't notice the issue the past days. Sorry :(

donmor avatar Sep 10 '22 14:09 donmor

The patch is modified to include Android 9 / 10. Saving a corrupted file on Android 9 can cease the corruption.

donmor avatar Sep 10 '22 14:09 donmor

Applied some tricks to the app. Now it'll decode the file ahead-of-time if on Android 11+ and using SAF, and try to remove all contents behind the first </html>\n, which is rendered as some kinds of codes in viewer. The actual file won't be shrinked though, until the file become larger than before.

Please take a look at the answers on stackoverflow for this (https://stackoverflow.com/questions/56902845/how-to-properly-overwrite-content-of-file-using-android-storage-access-framework), it fixes a similar issue and involves truncating the file prior to writing, I'm not confident that your approach of checking up to the first </html>\n would properly fix this issue.

Also take a look at https://issuetracker.google.com/issues/180526528 for further details.

Dialga avatar Sep 10 '22 18:09 Dialga

Okay I uploaded 2.3.0 to GitHub/Gitee/CoolApk (F-droid version needs some time to be built). Try it and let me know if it ceased your problem.

donmor avatar Sep 24 '22 14:09 donmor

Does anyone still have problem with 2.3.0 or later? I may close this if no problem reported.

donmor avatar Mar 05 '23 07:03 donmor

no

linonetwo avatar Mar 05 '23 08:03 linonetwo

No more bug reports since 2.3.0. Closing this. Reopen it if you're still concerned.

donmor avatar Mar 10 '23 14:03 donmor