From 448c411b322e18c4144180c3e4f07fe489fc3527 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 13 Oct 2012 23:31:15 +0100 Subject: [PATCH] Updated fileInfo structure Getting ready to keep track of titles too so that we can handle files being deleted from Dropbox --- tw5dropbox/appwiki/plugins/dropbox-app.js | 2 +- tw5dropbox/plugins/dropbox.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tw5dropbox/appwiki/plugins/dropbox-app.js b/tw5dropbox/appwiki/plugins/dropbox-app.js index c0a9df91e..a16516c60 100644 --- a/tw5dropbox/appwiki/plugins/dropbox-app.js +++ b/tw5dropbox/appwiki/plugins/dropbox-app.js @@ -31,7 +31,7 @@ exports.startup = function() { if(index) { $tw.wiki.addTiddlers(index.tiddlers); $tw.wiki.addTiddlers(index.shadows,true); - $tw.plugins.dropbox.fileRevisions = index.fileRevisions; + $tw.plugins.dropbox.fileInfo = index.fileInfo; } // Check for later versions of files on Dropbox $tw.plugins.dropbox.loadTiddlerFiles("/" + $tw.plugins.dropbox.wikiName + "/tiddlers",function(hadChanges) { diff --git a/tw5dropbox/plugins/dropbox.js b/tw5dropbox/plugins/dropbox.js index fd621fc9c..ffcd23686 100644 --- a/tw5dropbox/plugins/dropbox.js +++ b/tw5dropbox/plugins/dropbox.js @@ -20,7 +20,7 @@ var queryLoginMarker = "login=true"; $tw.plugins.dropbox = { client: null, // Dropbox.js client object - fileRevisions: {}, // Hashmap of revision strings for each tiddler file that has been retrieved from Dropbox + fileInfo: {}, // Hashmap of each file as retrieved from Dropbox: {versionTag:,title:} titleIsLoggedIn: "$:/plugins/dropbox/IsLoggedIn", titleUserName: "$:/plugins/dropbox/UserName", titlePublicAppUrl: "$:/plugins/dropbox/PublicAppUrl", @@ -124,13 +124,15 @@ $tw.plugins.dropbox.loadTiddlerFiles = function(path,callback) { isMetaFile = stat.path.lastIndexOf(".meta") === stat.path.length - 5; if(stat.isFile && !stat.isFolder && !isMetaFile) { // Don't load the file if the version tag shows it hasn't changed - var hasChanged = stat.versionTag !== $tw.plugins.dropbox.fileRevisions[stat.name]; + var fileInfo = $tw.plugins.dropbox.fileInfo[stat.name] || {}, + hasChanged = stat.versionTag !== fileInfo.versionTag; if(!hasChanged) { // Check if there is a metafile and whether it has changed var metafileName = stat.name + ".meta"; for(var p=0; p