Closed ParoTheParrot closed 7 months ago
Hi @ParoTheParrot , thanks for reporting! I can see the source of the issue indeed, I'll let you know once I come up with a fix. The problem indeed only affects backup, and not saving
Hey @ParoTheParrot , here's the plugin that should fix the issue (I've tested it with Timimi only, but there shouldn't be any difference for TiddlyDesktop), let me know if it helps (once updated to 2.10.1, you can remove it):
/***
|Name |FixPostSavePlugin|
|Description|This plugin fixes saving backups and RSS for TW 2.10.0; it should be used with 2.10.0 only (2.10.1 will include a fix)|
|Source |https://github.com/TiddlyWiki/TiddlyWikiClassic/issues/295#issuecomment-1886700602|
|Version |1.0.0|
|Author |Yakov Litvin|
***/
//{{{
// TODO: check version: if above 2.10.0, alert to remove this; if below 2.10.0, alert that this is only for 2.10.0
// don't change things for MainTiddlyServer, for versions other than 2.10.0
if(!window.tiddlyBackend && compareVersions(version, { major: 2, minor: 10, revision: 0 }) == 0) {
var orig_broken_saveEmpty = saveEmpty;
saveEmpty = function(localPath, original, posDiv) {
posDiv = posDiv || locateStoreArea(original);
if(!posDiv) {
alert(config.messages.emptyFailed);
return;
}
return orig_broken_saveEmpty.apply(this, arguments);
}
tw.io.getOriginalLocalPath = function() { return getLocalPath(document.location.toString()) };
saveChanges = function(onlyIfDirty) {
if(onlyIfDirty && !store.isDirty()) return;
clearMessage();
var t0 = new Date();
var msg = config.messages;
if(!window.allowSave()) {
alert(msg.notFileUrlError);
if(store.tiddlerExists(msg.saveInstructions))
story.displayTiddler(null, msg.saveInstructions);
return;
}
tw.io.saveMainAndReport(function postSave(savedOrPending, details) {
var co = config.options;
if (!config.saveByDownload && !config.saveByManualDownload && details && details.original) {
var localPath = tw.io.getOriginalLocalPath();
if(co.chkSaveBackups) saveBackup(localPath, details.original);
if(co.chkSaveEmptyTemplate) saveEmpty(localPath, details.original);
if(co.chkGenerateAnRssFeed) saveRss(localPath);
}
if(co.chkDisplayInstrumentation)
displayMessage("saveChanges " + (new Date() - t0) + " ms");
});
}
saveMain = function(localPath, original, posDiv, callback) {
var reportStatusAndHandle = function(successOrPending, localPath, revised) {
if(successOrPending) {
//# TODO: if possible, separate the success and pending cases
tw.io.onSaveMainSuccess(config.saveByDownload ?
getDataURI(revised) : "file://" + localPath,
revised, original);
} else {
tw.io.onSaveMainFail();
}
};
try {
var revised = updateOriginal(original, posDiv, localPath);
if(!callback || config.options.chkPreventAsyncSaving) {
var savedOrPending = tw.io.saveFile(localPath, revised);
reportStatusAndHandle(savedOrPending, localPath, revised);
if(callback) callback(savedOrPending, {
original: original
});
} else tw.io.saveFile(localPath, revised, function(success, details) {
reportStatusAndHandle(success, localPath, revised);
details.original = original;
callback(success, details);
});
} catch (ex) {
tw.io.onSaveMainFail(ex);
if(callback) callback(false, { original: original });
}
}
}
//}}}
Thanks @YakovL ! I tried the plugin with a 2.10.0 TiddlyWki and TiddlyDesktop. Results:
The configuration is "TiddlyWikiBackup" for the variable txtBackupFolder
.
Right, sounds like this need a deeper investigation. What was the previous TW version you used for which backups were saved successfully? chkSaveBackups
is enabled, right? What about chkPreventAsyncSaving
? If you put, before the line
if(co.chkSaveBackups) saveBackup(localPath, details.original);
in the plugin, this line:
alert(`chkSaveBackups: ${co.chkSaveBackups}, localPath: ${localPath}, details.original: ${details.original ? details.original.length + ' long' : details.original + ` (details: ${details})` }`)
what does it say during saving?
Hi, @ParoTheParrot , I've tried saving in TiddlyDesktop (0.0.18, for win64) and backups were saved successfully for me (both with empty txtBackupFolder
, i.e. to the same folder, and with txtBackupFolder
as backups
, with the folder ./backups
existing – does ./TiddlyWikiBackup
exist in your case?). Please try empty 2.10.0 with the plugin above, does saving backup work for you in this case? If yes, there may be a plugin conflict in your main TW, so you may want to try the patched core instead (see here)
Hi, @ParoTheParrot, any updates so far?
I started another approach with this test scenario: TiddlyDesktop 0.0.18, TiddlyWiki 2.10.0 + https://github.com/TiddlyWiki/TiddlyWikiClassic/issues/295#issuecomment-1886700602 Version 1.0.0.
Now everything works and backups are saved as usual, @YakovL !
Great! I'm closing the issue, but if there's some regression, feel free to reopen it
Since update of my TiddlyWiki from 2.9 to 2.10 I got this error in tiddly Desktop after saving: ReferenceError: localPath is not defined. strange: the TiddlyWiki itself was saved, but the backup wasn't . Any ideas or hints? TIA!