I stumbled across this 
<http://tobibeer.github.io/tb5/#Delete%20All%20Tiddlers%20By%20Filter>and 
thought it would make a good starting point for a JS macro.  Having tried 
it on a couple of TWs (where I had a ton of archaic temp/state tiddlers I 
wanted to remove) it seems there is a very destructive bug in there 
somewhere -- it destroys the TW (and since the wikis have passwords, they 
will no longer decrypt).  The size of one of the wikis went from ~6.5KB to 
103KB.  Ouch.

Here is Tobias' original code:

var filter = "tag[FOO]"; 
filter = "[all[tiddlers]!prefix[$]" + subfilter + "]";
var tids = $tw.wiki.filterTiddlers(filter, null); 
if(confirm('Delete all ' + tids.length + '?\n\n' + tids)){
  for(var t=0; t<tids.length; t++) {
    $tw.wiki.deleteTiddler(tids[t]); 
  } 
}


Noticing the stray subfilter variable, I cleaned it up and then used this:

var filter = "[prefix[$:/temp/state/1]]";
var tids = $tw.wiki.filterTiddlers(filter, null);
if(confirm('Delete all ' + tids.length + '?\n\n' + tids)){
  for(var t=0; t<tids.length; t++) {
    $tw.wiki.deleteTiddler(tids[t]);
  }
}


If I use that filter in the filter search input in TW, it works as expected.  
When running the code above, it lists the exact same tiddlers (AFAICT), yet, it 
destroys the TW on confirming the dialog.

Anyone see a problem? What am I missing?

TIA

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c9982b8b-35c9-408a-b293-f5687c9ddae2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to