Commit 2b6d19ea authored by Sven Franck's avatar Sven Franck

remove method updated in revisionstorage

parent 55904db0
...@@ -212,10 +212,6 @@ jIO.addStorageType('revision', function (spec, my) { ...@@ -212,10 +212,6 @@ jIO.addStorageType('revision', function (spec, my) {
revs_info = [], revs_info = [],
selected_node = doctree; selected_node = doctree;
if (doc._rev === undefined && priv.missing_revision){
doc._rev = priv.missing_revision;
}
selectNode = function (node) { selectNode = function (node) {
var i; var i;
if (typeof node.rev !== "undefined") { if (typeof node.rev !== "undefined") {
...@@ -465,7 +461,6 @@ jIO.addStorageType('revision', function (spec, my) { ...@@ -465,7 +461,6 @@ jIO.addStorageType('revision', function (spec, my) {
doctree, doctree,
command.cloneOption(), command.cloneOption(),
function (response) { function (response) {
that.success({ that.success({
"ok":true, "ok":true,
"id":docid, "id":docid,
...@@ -684,8 +679,7 @@ jIO.addStorageType('revision', function (spec, my) { ...@@ -684,8 +679,7 @@ jIO.addStorageType('revision', function (spec, my) {
return; return;
} }
} }
// get doctree
// get doctree
that.addJob( that.addJob(
"get", "get",
priv.substorage, priv.substorage,
...@@ -694,91 +688,35 @@ jIO.addStorageType('revision', function (spec, my) { ...@@ -694,91 +688,35 @@ jIO.addStorageType('revision', function (spec, my) {
function (response) { function (response) {
response._conflicts = priv.getLeavesFromDocumentTree(response); response._conflicts = priv.getLeavesFromDocumentTree(response);
// really necessary...?
if (del_rev === undefined) { if (del_rev === undefined) {
// single leaf = can be deleted // no revision provided
if (response._conflicts.length === 1) {
f.removeDocument(command.getDocId()+"."+
response._conflicts[0]);
delete response._conflicts;
} else {
// multiple leaves = only if deleting attachment,
// because unique document.revision/attachment
if (typeof command.getAttachmentId() === "string"){
for (i = 0; i < response._conflicts.length; i += 1){
del_rev = response._conflicts[i];
that.addJob(
"get",
priv.substorage,
command.getDocId()+"."+response._conflicts[i],
option,
function (nested_response) {
if (typeof nested_response._attachments === "object") {
if (nested_response._attachments[command.getAttachmentId()] !== undefined){
revision_found = true;
correct_revision = del_rev;
}
}
if ( revision_count === response._conflicts.length-1 &&
revision_found !== true ){
that.error({
"status": 404,
"statusText": "Not Found",
"error": "not_found",
"message": "Attachment not found, please check attachment ID",
"reason": "Incorrect Attachment ID"
});
return;
}
if (revision_found === true ){
priv.missing_revision = correct_revision;
delete response._conflicts;
f.removeDocument(command.getDocId()+"."+
correct_revision+"/"+command.getAttachmentId());
}
revision_count += 1;
},
function (err) {
that.error({
"status": 404,
"statusText": "Not Found",
"error": "not_found",
"message": "Attachment not found, please check document ID",
"reason": "Incorrect document ID"
});
}
);
}
} else {
// conflict
// return conflict message here, so user can pick a document version
that.error({ that.error({
"status": 409, "status": 409,
"statusText": "Conflict", "statusText": "Conflict",
"error": "conflict", "error": "conflict",
"message": "Document update conflict.", "message": "Document update conflict.",
"reason": "Cannot delete a document without revision when multiple versions exist" "reason": "Cannot delete a document without revision"
}); });
return; return;
}
}
} else { } else {
// revision provided // revision provided
if (typeof command.getAttachmentId() === "string"){ if (typeof command.getAttachmentId() === "string"){
f.removeDocument(command.getDocId()+"."+del_rev+"/"+ f.removeDocument(command.getDocId()+"."+del_rev+"/"+
command.getAttachmentId()); command.getAttachmentId());
} else { } else {
if (priv.isRevisionALeaf(del_rev, response._conflicts)){ if (del_rev ===
f.removeDocument(command.getDocId()+"."+del_rev); priv.getWinnerRevisionFromDocumentTree(response)[0].rev
){
priv.dummy = true;
f.removeDocument(command.getDocId()+"."+
del_rev);
} else { } else {
that.error({ that.error({
"status": 409, "status": 409,
"statusText": "Conflict", "statusText": "Conflict",
"error": "conflict", "error": "conflict",
"message": "Document update conflict.", "message": "Document update conflict.",
"reason": "Trying to remove an outdated revision" "reason": "Trying to remove non-latest revision"
}); });
return; return;
} }
...@@ -790,7 +728,7 @@ jIO.addStorageType('revision', function (spec, my) { ...@@ -790,7 +728,7 @@ jIO.addStorageType('revision', function (spec, my) {
"status": 404, "status": 404,
"statusText": "Not Found", "statusText": "Not Found",
"error": "not_found", "error": "not_found",
"message": "Document tree not found, please check document ID", "message": "Document tree not found, please checkdocument ID",
"reason": "Incorrect document ID" "reason": "Incorrect document ID"
}); });
return; return;
......
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