mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-12 12:59:57 +00:00
System tiddler syncing (#4987)
* First pass at a fix for system tiddler sync issues * Add new filter syncFromServer * Undo previous attempt at a fix * Added a flag to control sync of system tiddlers from server
This commit is contained in:
parent
0d434583ec
commit
e2bea854b6
@ -28,6 +28,9 @@ exports.handler = function(request,response,state) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(state.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "no") {
|
||||
filter += "+[!is[system]]";
|
||||
}
|
||||
var excludeFields = (state.queryParameters.exclude || "text").split(","),
|
||||
titles = state.wiki.filterTiddlers(filter);
|
||||
response.writeHead(200, {"Content-Type": "application/json"});
|
||||
|
@ -305,7 +305,8 @@ Syncer.prototype.syncFromServer = function() {
|
||||
self.pollTimerId = null;
|
||||
self.syncFromServer.call(self);
|
||||
},self.pollTimerInterval);
|
||||
};
|
||||
},
|
||||
syncSystemFromServer = (self.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes" ? true : false);
|
||||
if(this.syncadaptor && this.syncadaptor.getUpdatedTiddlers) {
|
||||
this.logger.log("Retrieving updated tiddler list");
|
||||
cancelNextSync();
|
||||
@ -320,9 +321,11 @@ Syncer.prototype.syncFromServer = function() {
|
||||
self.titlesToBeLoaded[title] = true;
|
||||
});
|
||||
$tw.utils.each(updates.deletions,function(title) {
|
||||
delete self.tiddlerInfo[title];
|
||||
self.logger.log("Deleting tiddler missing from server:",title);
|
||||
self.wiki.deleteTiddler(title);
|
||||
if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
|
||||
delete self.tiddlerInfo[title];
|
||||
self.logger.log("Deleting tiddler missing from server:",title);
|
||||
self.wiki.deleteTiddler(title);
|
||||
}
|
||||
});
|
||||
if(updates.modifications.length > 0 || updates.deletions.length > 0) {
|
||||
self.processTaskQueue();
|
||||
@ -365,9 +368,11 @@ Syncer.prototype.syncFromServer = function() {
|
||||
}
|
||||
// Delete any tiddlers that were previously reported but missing this time
|
||||
$tw.utils.each(previousTitles,function(title) {
|
||||
delete self.tiddlerInfo[title];
|
||||
self.logger.log("Deleting tiddler missing from server:",title);
|
||||
self.wiki.deleteTiddler(title);
|
||||
if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
|
||||
delete self.tiddlerInfo[title];
|
||||
self.logger.log("Deleting tiddler missing from server:",title);
|
||||
self.wiki.deleteTiddler(title);
|
||||
}
|
||||
});
|
||||
self.processTaskQueue();
|
||||
});
|
||||
|
@ -1,3 +1,3 @@
|
||||
title: $:/config/SyncFilter
|
||||
|
||||
[is[tiddler]] -[[$:/core]] -[prefix[$:/StoryList]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/isEncrypted]] -[prefix[$:/status/]] -[prefix[$:/state/]] -[prefix[$:/temp/]]
|
||||
[is[tiddler]] -[[$:/core]] -[[$:/library/sjcl.js]] -[prefix[$:/boot/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/isEncrypted]] -[prefix[$:/status/]] -[prefix[$:/state/]] -[prefix[$:/temp/]]
|
||||
|
3
core/wiki/config/SyncSystemTiddlersFromServer.tid
Normal file
3
core/wiki/config/SyncSystemTiddlersFromServer.tid
Normal file
@ -0,0 +1,3 @@
|
||||
title: $:/config/SyncSystemTiddlersFromServer
|
||||
|
||||
no
|
Loading…
Reference in New Issue
Block a user