fiatjaf / tiddlywiki-remotestorage

a syncadaptor plugin that saves tiddlers on custom remoteStorage directories
https://tiddly.fiatjaf.com/
21 stars 4 forks source link

Make config settings permanent #2

Closed Mirodin closed 6 years ago

Mirodin commented 6 years ago

Thank you for fixing #1, I really love this plugin already.

Since I want to migrate a hugh number of wikis (>40) to remoteStorage I setup a simple HTTP server to serve bare single file wikis with the respective plugins enabled. To setup a new wiki I take the wiki from https://tiddly.alhur.es change the title, subtitle, settings and install some plugins before hitting "Save" and uploading the resulting "dump" to my server.

The problem is that this does not preserve the two tiddlers which set the namespace and the privacy setting. So I have to do this configuration for every wiki on every device which is quite error-prone. I would think that those tiddlers other than saved in Local Storage should be saved too when downloading a single file copy.

I do not see any security flaws if one might see the "path" on my remote storage in the resulting HTML file for this wiki as the login credentials are not stored. Due to the remoteStorage.js library it is quite easy to login with a new device only once and using this permission for all wikis since authorization is determined by host.

So my feature request would be to store $:/plugins/fiatjaf/remoteStorage/private and $:/plugins/fiatjaf/remoteStorage/namespace along with the other tiddlers when hitting "Save".

fiatjaf commented 6 years ago

Thank you very much for the detailed description.

The tiddlers are already being saved when you click "Save" (the plugin doesn't control that, and the default is to save everything), but the plugin was overriding (with either the values on localStorage or the default values when those are not present) them when it is loaded.

I believe this was fixed now on ef224c476aa65572c0a861979902ba560c347fff. Let's hope no new bugs were introduced.

Please let me know.

Mirodin commented 6 years ago

Sorry to bother you again but it seems this issue was not fixed/came back. When I open my TW file locally (via file protocol) I can retrieve the configuration tiddlers which are written into the file as they should - I checked this with a simple search in my text editor.

image4

When I open the same wiki file over HTTP there is no tiddler text to retrieve anymore thus messing up my synchronisation for all wikis since all are served from the same host and the value retrieved from localStorage is empty making the plugin check the default locations.

image5

P.S.: I emptied my localStorage for every test so there is always a clean start. When I do not clean it the last values I sat gets used for all wikis afterwards.

Mirodin commented 6 years ago

I feel like I should add steps to reproduce and test this:

  1. Visit tiddly.alhur.es and download a copy
  2. Make changes, set remoteStorage config and save file again to make them permanent
  3. Clear localStorage to level the playing-field
  4. Open file via file protocol
  5. Check if everything was saved (retrieving the config settings works)
  6. Upload file to HTTP server
  7. Open file via HTTP protocol
  8. Retrieving the config settings does not work anymore and the fields in remoteStorage syncadaptor settings are empty (or filled with the last set values if localStorage was not cleared before)

I hope this helps in hunting down the problem :)

fiatjaf commented 6 years ago

I wish there were tests for this plugin, but I can't automate even the build process, not to say tests. I'm glad there's @Mirodin testing stuff here (sorry). The steps to reproduce were great.

I guess this is finally fixed now (on cbcacc1f5bd9694d65e0760394795089fb64a5c1).