Commit f691326f authored by Tristan Cavelier's avatar Tristan Cavelier

fix bug in post and put from revisionstorage.js

put {"_id":"test"} when "test" already exists -> conflicts
revisions can pass the checkRevisionFormat function now
parent 32ee4fb8
......@@ -300,13 +300,13 @@ jIO.addStorageType('revision', function (spec, my) {
doc = command.cloneDoc();
docid = command.getDocId();
if (typeof doc._rev === "string" &&
priv.checkRevisionFormat(doc._rev)) {
!priv.checkRevisionFormat(doc._rev)) {
that.error({
"status": 31,
"statusText": "Wrong Revision Format",
"error": "wrong_revision_format",
"message": "The document previous revision does not match "+
"[0-9]+-[0-9a-zA-Z]+",
"^[0-9]+-[0-9a-zA-Z]+$",
"reason": "Previous revision is wrong"
});
return;
......@@ -315,6 +315,9 @@ jIO.addStorageType('revision', function (spec, my) {
doc._id = priv.generateUuid();
docid = doc._id;
}
if (priv.update_doctree_allowed === undefined) {
priv.update_doctree_allowed = true;
}
f.getDocumentTree = function () {
var option = command.cloneOption();
if (option["max_retry"] === 0) {
......@@ -327,7 +330,17 @@ jIO.addStorageType('revision', function (spec, my) {
option,
function (response) {
doctree = response;
f.postDocument("put");
if (priv.update_doctree_allowed) {
f.postDocument("put");
} else {
that.error({
"status": 409,
"statusText": "Conflict",
"error": "conflict",
"message": "Cannot update a document",
"reason": "Document update conflict"
});
}
}, function (err) {
switch(err.status) {
case 404:
......@@ -398,6 +411,9 @@ jIO.addStorageType('revision', function (spec, my) {
* @param {object} command The JIO command
*/
that.put = function (command) {
if (command.cloneDoc()._rev === undefined) {
priv.update_doctree_allowed = false;
}
that.post(command);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment