mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-22 23:16:53 +00:00
Better error trapping for WebDAV saver
Without these checks we get a startup crash when using TiddlyWiki in client-server configuration.
This commit is contained in:
parent
f0ff1f993e
commit
91b341e8e0
@ -29,16 +29,20 @@ var PutSaver = function(wiki) {
|
||||
type: "OPTIONS",
|
||||
callback: function(err, data, xhr) {
|
||||
// Check DAV header http://www.webdav.org/specs/rfc2518.html#rfc.section.9.1
|
||||
if(!err) {
|
||||
self.serverAcceptsPuts = xhr.status === 200 && !!xhr.getResponseHeader("dav");
|
||||
}
|
||||
}
|
||||
});
|
||||
// Retrieve ETag if available
|
||||
$tw.utils.httpRequest({
|
||||
url: uri,
|
||||
type: "HEAD",
|
||||
callback: function(err, data, xhr) {
|
||||
if(!err) {
|
||||
self.etag = xhr.getResponseHeader("ETag");
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -64,15 +68,15 @@ PutSaver.prototype.save = function(text, method, callback) {
|
||||
headers: headers,
|
||||
data: text,
|
||||
callback: function(err, data, xhr) {
|
||||
if (xhr.status === 200 || xhr.status === 201) {
|
||||
if(err) {
|
||||
callback(err);
|
||||
} if(xhr.status === 200 || xhr.status === 201) {
|
||||
self.etag = xhr.getResponseHeader("ETag");
|
||||
callback(null); // success
|
||||
}
|
||||
else if (xhr.status === 412) { // edit conflict
|
||||
} else if(xhr.status === 412) { // edit conflict
|
||||
var message = $tw.language.getString("Error/EditConflict");
|
||||
callback(message);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
callback(xhr.responseText); // fail
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user