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

On Node.js, new tiddlers with Type text/plain are saved in a file with double extension '.txt.tid' #2558

Closed
JulioCantarero opened this issue Aug 26, 2016 · 10 comments

Comments

@JulioCantarero
Copy link

I did a clean test in a new TW5 new server instance using version 5.1.13. I am running TW5 on Node.js in Windows 10.
When I create a new tiddler with Type text/plain, it is saved in a file with double extension '.txt.tid'. This shows in the server log (see last line):

$ tiddlywiki --server --verbose
Serving on 127.0.0.1:8080
(press ctrl-C to exit)
Boot log:
  Startup task: load-modules
  Startup task: info after: load-modules before: startup
  Startup task: startup after: load-modules
  Startup task: story after: startup
  Startup task: commands platforms: node after: story
syncer-server: Dispatching 'save' task: $:/StoryList
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\$__StoryList.tid
syncer-server: Dispatching 'save' task: $:/StoryList
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\$__StoryList.tid
syncer-server: Dispatching 'save' task: Draft of 'New Tiddler 1'
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\Draft_of_'New_Tiddler_1'.tid
syncer-server: Dispatching 'save' task: Draft of 'New Tiddler 1'
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\Draft_of_'New_Tiddler_1'.tid
syncer-server: Dispatching 'save' task: Draft of 'New Tiddler 1'
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\Draft_of_'New_Tiddler_1'.tid
syncer-server: Dispatching 'save' task: Draft of 'New Tiddler 1'
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\Draft_of_'New_Tiddler_1'.tid
syncer-server: Dispatching 'save' task: Draft of 'New Tiddler 1'
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\Draft_of_'New_Tiddler_1'.tid
syncer-server: Dispatching 'save' task: Draft of 'New Tiddler 1'
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\Draft_of_'New_Tiddler_1'.tid
syncer-server: Dispatching 'delete' task: Draft of 'New Tiddler 1'
FileSystem: Deleted file D:\TW5onNode.js\Test\tiddlers\Draft_of_'New_Tiddler_1'.tid
syncer-server: Dispatching 'save' task: $:/StoryList
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\$__StoryList.tid
syncer-server: Dispatching 'save' task: Test Problem with TXT Type in Filenames
FileSystem: Saved file D:\TW5onNode.js\Test\tiddlers\Test_Problem_with_TXT_Type_in_Filenames.txt.tid

AFAIK, prior to 5.1.13 or 5.1.12, TW5 was saving these tiddlers in a simple '.tid' file.
Actually, this problem also happens with existing TXT tiddlers in upgraded TW5 on NOde.js, whose files are renamed to ".txt.tid" when the TXT tiddler is edited, leaving an undeleted Draft Of file behind.

@Jermolene
Copy link
Owner

Thanks @JulioCantarero I can confirm the problem.

@sukima this looks like another side effect of your recent changes, please could you look into this? Many thanks!

@Awerick
Copy link

Awerick commented Feb 10, 2017

Anything new on this issue?
The problem still exists (so it is independent from the closed #2647):
TiddlyWiki: version 5.1.14-prerelease

This also affects markdown files (when using the markdown plugin):
Markdown files get the suffix .md.tid instead of only .md. This is not intended, right?

This also leads to an error message when aborting an edit – which is supposed to delete the draft:

FileSystem: Saved file /home/awerick/tiddlywiki/tiddlers/Draft_of_'New_Tiddler_1'.md.tid
syncer-server-filesystem: Dispatching 'delete' task: Draft of 'New Tiddler 1'
Sync error while processing 'Draft of 'New Tiddler 1'':
Error: ENOENT, unlink '/home/awerick/tiddlywiki/tiddlers/Draft_of_'New_Tiddler_1'.md'

@pmario
Copy link
Contributor

pmario commented Feb 10, 2017

Markdown files get the suffix .md.tid instead of only .md. This is not intended, right?

tiddlers always need to have a .tid extension, because they have a special format. .. so this is intentional.

If you want it to have x.md you will need to add a x.meta file, that contains the tiddlywiki header. eg: title, tags, field ,,, and so on

@Jermolene
Copy link
Owner

Hi @Awerick

Markdown files get the suffix .md.tid instead of only .md. This is not intended, right?
This also leads to an error message when aborting an edit – which is supposed to delete the draft:

Thanks, you've uncovered another problem with the filesystem adaptor. I'll post an update soon.

Jermolene added a commit that referenced this issue Feb 11, 2017
The code here had got a bit broken by some PRs that I should have
checked more carefully. I’ve done a major refactoring which will
hopefully make it easier to understand, and fixes a number of problems:

* Problem with eg .md tiddlers not being deleted correctly
* Problem with Windows path separators not being usable within
$:/config/FileSystemPaths on Windows
* Problem with filename clashes not being detected correctly when
saving to a different directory via $:/config/FileSystemPaths
* Enables slashes within tiddler titles to be mapped into folders
* Enables plain text files like .md and .css to be saved with .meta
files instead of as .tid files (see #2558)
* No longer replaces spaces with underscores

As this is such a major update, I’d be grateful if Node.js users could
give it a careful run through — in particular, you’ll need to try
creating new tiddlers of various types and ensure that the expected
files are created.
@Jermolene
Copy link
Owner

Hi @Awerick @pmario I've done a major refactoring of the file system adaptor, which should fix the deletion problem raised by @Awerick, as well as the OP.

3708f6c

The prerelease isn't on npm so you'll have to install it as detailed here:

http://tiddlywiki.com/#Installing%20TiddlyWiki%20Prerelease%20on%20Node.js

@Jermolene
Copy link
Owner

Sorry @JulioCantarero, I closed this in error, please close it yourself when you've confirmed the fix.

@Jermolene Jermolene reopened this Feb 12, 2017
@Awerick
Copy link

Awerick commented Feb 13, 2017

Ah! Thanks @pmario, I misunderstood this issue and TW's file concept then, sorry:
When I read that plaintext files should not have a double extension (.txt.tid) but only .tid,
I mistakenly assumed markdown files should also not have a double extension (.md.tid) and it should be .md. But now I understand the intention of the .tid (and that both types use it).

@Jermolene:

  • Thanks! Drafts are now deleted correctly (no error message when aborting an edit).

  • However: TiddlyWiki now creates a new, empty directory for each new tiddler! (Bug!?)

  • Furthermore the new commit changes the default behavior for new files, correct?

    Previously new files that had not the default type (text/vnd.tiddlywiki) (e.g. plaintext files and markdown files) were created with the extension .<TYPE>.tid. Now new files are created with the extension .<TYPE> and with an additional .<TYPE>.meta file. (– Is there actually an option to choose the default behavior for this manually?)

    Is this a "solution" for this issue? I understand the intention of this issue to keep the previous behavior (using .<TYPE>.tid) with the only change, that plaintext files should not be saved as .txt.tid but only .tid. – But maybe I still misinterpret the intention of this issue?

@pmario
Copy link
Contributor

pmario commented Feb 13, 2017

@Awerick
There have been quite some changes to the filesystemadaptor now. For every known tiddler type, there will be an extension and a meta file now. Except for tiddlywiki files they are still .tid.

The important thing is, that the filename has not much to do with the tiddler name. So the title field defines the tiddler name. The file name is just a "placeholder" to identify it as a file.

So if you like you can create a new tiddler.x.y.z.txt.tid with some experimentation ;)

@Jermolene
Copy link
Owner

Hi @Awerick

  • Thanks! Drafts are now deleted correctly (no error message when aborting an edit).

Great.

  • However: TiddlyWiki now creates a new, empty directory for each new tiddler! (Bug!?)

That problem should be fixed now.

  • Furthermore the new commit changes the default behavior for new files, correct?

Correct.

Previously new files that had not the default type (text/vnd.tiddlywiki) (e.g. plaintext files and markdown files) were created with the extension .<TYPE>.tid. Now new files are created with the extension .<TYPE> and with an additional .<TYPE>.meta file. (– Is there actually an option to choose the default behavior for this manually?)

Known file types are now saved as a separate *.ext and *.ext.meta file. The goal here is to make it easier to edit the tiddler files with proper syntax colouring in a separate editor, and easier to re-use tiddler files.

Is this a "solution" for this issue? I understand the intention of this issue to keep the previous behavior (using .<TYPE>.tid) with the only change, that plaintext files should not be saved as .txt.tid but only .tid. – But maybe I still misinterpret the intention of this issue?

My goal with the recent commit was to fix a number of issues that had accumulated thanks to my mistakenly merging some PRs that broke previous behaviour.

@JulioCantarero
Copy link
Author

I tried 5.1.14-prerelease using node.js on Windows 10 and the previous problem with txt files did not happen. Thank you!

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