1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Fixes to ensure revision field is always a string

TiddlyWeb returns it as a number, which seems like it might be an
accident.
This commit is contained in:
Jeremy Ruston 2013-03-18 10:13:36 +00:00
parent d14c61ef45
commit 5e12868e76
2 changed files with 14 additions and 2 deletions

View File

@ -294,7 +294,7 @@ Syncer.prototype.enqueueSyncTask = function(task) {
// Fill in some tiddlerInfo if the tiddler is one we haven't seen before // Fill in some tiddlerInfo if the tiddler is one we haven't seen before
if(!$tw.utils.hop(this.tiddlerInfo,task.title)) { if(!$tw.utils.hop(this.tiddlerInfo,task.title)) {
this.tiddlerInfo[task.title] = { this.tiddlerInfo[task.title] = {
revision: "0", revision: null,
adaptorInfo: {}, adaptorInfo: {},
changeCount: -1 changeCount: -1
} }

View File

@ -121,8 +121,16 @@ TiddlyWebAdaptor.prototype.getSkinnyTiddlers = function(callback) {
if(err) { if(err) {
return callback(err); return callback(err);
} }
// Process the tiddlers to make sure the revision is a string
var tiddlers = JSON.parse(data);
for(var t=0; t<tiddlers.length; t++) {
var tiddlerFields = tiddlers[t];
if(typeof tiddlerFields.revision === "number") {
tiddlerFields.revision = tiddlerFields.revision.toString();
}
}
// Invoke the callback with the skinny tiddlers // Invoke the callback with the skinny tiddlers
callback(null,JSON.parse(data)); callback(null,tiddlers);
} }
}); });
}; };
@ -237,6 +245,10 @@ TiddlyWebAdaptor.prototype.convertTiddlerFromTiddlyWebFormat = function(data) {
result[title] = tiddlerFields[title]; result[title] = tiddlerFields[title];
} }
}); });
// Make sure the revision is expressed as a string
if(typeof result.revision === "number") {
result.revision = result.revision.toString();
}
// Some unholy freaking of content types // Some unholy freaking of content types
if(result.type === "text/javascript") { if(result.type === "text/javascript") {
result.type = "application/javascript"; result.type = "application/javascript";