1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +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:
saqimtiaz 2020-11-19 16:59:02 +01:00 committed by GitHub
parent 0d434583ec
commit e2bea854b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 8 deletions

View File

@ -28,6 +28,9 @@ exports.handler = function(request,response,state) {
return; return;
} }
} }
if(state.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "no") {
filter += "+[!is[system]]";
}
var excludeFields = (state.queryParameters.exclude || "text").split(","), var excludeFields = (state.queryParameters.exclude || "text").split(","),
titles = state.wiki.filterTiddlers(filter); titles = state.wiki.filterTiddlers(filter);
response.writeHead(200, {"Content-Type": "application/json"}); response.writeHead(200, {"Content-Type": "application/json"});

View File

@ -305,7 +305,8 @@ Syncer.prototype.syncFromServer = function() {
self.pollTimerId = null; self.pollTimerId = null;
self.syncFromServer.call(self); self.syncFromServer.call(self);
},self.pollTimerInterval); },self.pollTimerInterval);
}; },
syncSystemFromServer = (self.wiki.getTiddlerText("$:/config/SyncSystemTiddlersFromServer") === "yes" ? true : false);
if(this.syncadaptor && this.syncadaptor.getUpdatedTiddlers) { if(this.syncadaptor && this.syncadaptor.getUpdatedTiddlers) {
this.logger.log("Retrieving updated tiddler list"); this.logger.log("Retrieving updated tiddler list");
cancelNextSync(); cancelNextSync();
@ -320,9 +321,11 @@ Syncer.prototype.syncFromServer = function() {
self.titlesToBeLoaded[title] = true; self.titlesToBeLoaded[title] = true;
}); });
$tw.utils.each(updates.deletions,function(title) { $tw.utils.each(updates.deletions,function(title) {
delete self.tiddlerInfo[title]; if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
self.logger.log("Deleting tiddler missing from server:",title); delete self.tiddlerInfo[title];
self.wiki.deleteTiddler(title); self.logger.log("Deleting tiddler missing from server:",title);
self.wiki.deleteTiddler(title);
}
}); });
if(updates.modifications.length > 0 || updates.deletions.length > 0) { if(updates.modifications.length > 0 || updates.deletions.length > 0) {
self.processTaskQueue(); self.processTaskQueue();
@ -365,9 +368,11 @@ Syncer.prototype.syncFromServer = function() {
} }
// Delete any tiddlers that were previously reported but missing this time // Delete any tiddlers that were previously reported but missing this time
$tw.utils.each(previousTitles,function(title) { $tw.utils.each(previousTitles,function(title) {
delete self.tiddlerInfo[title]; if(syncSystemFromServer || !self.wiki.isSystemTiddler(title)) {
self.logger.log("Deleting tiddler missing from server:",title); delete self.tiddlerInfo[title];
self.wiki.deleteTiddler(title); self.logger.log("Deleting tiddler missing from server:",title);
self.wiki.deleteTiddler(title);
}
}); });
self.processTaskQueue(); self.processTaskQueue();
}); });

View File

@ -1,3 +1,3 @@
title: $:/config/SyncFilter 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/]]

View File

@ -0,0 +1,3 @@
title: $:/config/SyncSystemTiddlersFromServer
no