Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple extensions for tiddlers on the filesystem with NodeJS #2647

Closed
laomaiweng opened this issue Dec 5, 2016 · 6 comments
Closed

Multiple extensions for tiddlers on the filesystem with NodeJS #2647

laomaiweng opened this issue Dec 5, 2016 · 6 comments

Comments

@laomaiweng
Copy link
Contributor

Hi there,

I'm getting a behavior that seems weird and looks like a bug to me: I run TiddlyWiki on NodeJS, and my tiddlers get saved to the filesystem with multiple duplicate extensions.
E.g. for the Story tiddler: every time I start up TiddlyWiki, one more level of .tid gets added to the filename. Thus currently, I have the following Story tiddler files in my tiddlers folder:

$__StoryList.tid.tid
$__StoryList.tid.tid.tid
$__StoryList.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid.tid

As for the other tiddlers, same story, every time I modify a tiddler, it gets saved with one more level of .tid (starting with 2), e.g.:

some_tiddler.tid.tid
some_tiddler.tid.tid.tid

This is also causing me ENOENT unlink errors with drafts, since TiddlyWiki tries to remove Draft_of_'blah'.tid which doesn't exist (Draft_of_'blah'.tid.tid does). Hence when I restart the wiki, all drafts that I committed/cancelled previously are back again.

All imported files/images have multiple extensions as well, e.g. some_pic.png.png and some_pic.png.png.meta.

May be related to #2558 and #1570.

I should also mention that I'm accessing the wiki through an Apache proxy (for HTTPS), and that the wiki is hosted in a subfolder (non-empty pathprefix).

Any thoughts?

I'd be happy to provide more details as needed.

@laomaiweng
Copy link
Contributor Author

More specifically, after digging a bit in plugins/tiddlywiki/filesystem/filesystemadaptor.js and adding some debug output to FileSystemAdaptor.addFileExtension(), I get this:

[addFileExtension] file=/blah/tiddlers/$__StoryList.tid.[…].tid / extension=.tid / $tw.utils.strEndsWith(file,extension)=false

This looks, to say the least, confusing.

@laomaiweng
Copy link
Contributor Author

Ok, got it.
The bug is in core/modules/utils/utils.js, in function strEndsWith: when going through the else branch of the if(str.endsWith) condition, if position is not set we set it to str.length, then subtract str.length from it => position === 0. We should be subtracting ending.length.

@laomaiweng
Copy link
Contributor Author

Hmmm, I see that this bug has already been fixed on master. Closing then, sorry for the noise.
I'll go fix my wiki now.

@vladimir-lu
Copy link

To be precise, this was fixed in f1090d7 as part of #2572 (and the bug is present in the latest release 5.1.13). I am seeing some strange behavior with tiddlers not being saved that I suspect is caused by this bug. It sounds critical enough to issue an update on npm or a new patch release to address it (pretty please)

@Wirone
Copy link

Wirone commented Mar 9, 2017

I have 5.1.13 installed and I am facing with the same behavior.

$__config_Navigation_UpdateAddressBar.tid.tid
$__config_PageControlButtons_Visibility_$__core_ui_Buttons_more-page-actions.tid.tid
$__DefaultTiddlers.tid.tid
$__plugins_tiddlywiki_codemirror.json.tid
$__plugins_tiddlywiki_highlight.json.tid
$__SiteSubtitle.tid.tid
$__SiteTitle.tid.tid
$__StoryList.tid.tid
$__StoryList.tid.tid.tid
$__StoryList.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid
$__StoryList.tid.tid.tid.tid.tid.tid.tid.tid
Test.tid.tid

Running through forever, but the same is when run with tiddlywiki.

@sukima
Copy link
Contributor

sukima commented Mar 10, 2017

It sounds critical enough to issue an update on npm or a new patch release to address it (pretty please)

Ping @Jermolene !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants