finalizeTransaction: function(transactionId, mServerContentBundle, done) { if (window.requestFileSystem) { window.requestFileSystem( window.LocalFileSystem.PERSISTENT, 0, function(fs) { var tempPath = 'directresult/unfinishedTransactions/contentbundles/'+mServerContentBundle.id+'/'+transactionId, finalPath = 'directresult/finishedTransactions/contentbundles/'+mServerContentBundle.id; fs.root.getDirectory( tempPath, {create: true, exclusive: false}, // just in case we get invoked REALLY early function(tp) { fs.root.getDirectory( 'directresult/finishedTransactions', {create: true, exclusive: false}, function(ip) { fs.root.getDirectory( finalPath, {create: true, exclusive: false}, function(fp) { tp.moveTo(tp, fp, transactionId, done, function(e) { this.rollbackTransaction(transactionId, mServerContentBundle, function() { this.showError('Failed to move dir entry: '+JSON.stringify(e)); }.bind(this)); }); }.bind(this), function(e) { this.rollbackTransaction(transactionId, mServerContentBundle, function() { this.showError('Failed to get final directory for '+finalPath+': '+JSON.stringify(e)); }.bind(this)); }.bind(this)); }.bind(this), function(e) { this.rollbackTransaction(transactionId, mServerContentBundle, function() { this.showError('Failed to get intermediate directory: '+JSON.stringify(e)); }.bind(this)); }.bind(this)); }.bind(this), function(e) { this.rollbackTransaction(transactionId, mServerContentBundle, function() { this.showError('Failed to get temp directory for '+tempPath+': '+JSON.stringify(e)); }.bind(this)); }.bind(this)); }.bind(this), function(e) { this.rollbackTransaction(transactionId, mServerContentBundle, function() { this.showError('Failed to get fs: '+JSON.stringify(e)); }.bind(this)); }.bind(this)); } else { done(); } }