Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Yaxel Perez
jio
Commits
f2943ed8
Commit
f2943ed8
authored
Dec 31, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replicaterevisionstorage upgraded + tests
parent
5a50c92f
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1173 additions
and
858 deletions
+1173
-858
src/jio.storage/replicaterevisionstorage.js
src/jio.storage/replicaterevisionstorage.js
+29
-29
test/jio.storage/replicaterevisionstorage.tests.js
test/jio.storage/replicaterevisionstorage.tests.js
+1144
-829
No files found.
src/jio.storage/replicaterevisionstorage.js
View file @
f2943ed8
...
...
@@ -22,7 +22,7 @@
module
(
jIO
);
}([
'
jio
'
],
function
(
jIO
)
{
"
use strict
"
;
jIO
.
addStorage
Type
(
'
replicaterevision
'
,
function
(
spec
)
{
jIO
.
addStorage
(
'
replicaterevision
'
,
function
(
spec
)
{
var
that
=
this
,
priv
=
{};
spec
=
spec
||
{};
...
...
@@ -217,16 +217,9 @@
command
.
success
();
}
if
(
!
param
.
_id
)
{
return
callback
({
"
status
"
:
501
});
return
callback
({
"
status
"
:
501
});
}
priv
.
check
(
command
,
param
,
option
,
callback
);
priv
.
check
(
command
,
param
,
option
,
callback
);
};
/**
...
...
@@ -264,6 +257,16 @@
callback
=
callback
||
priv
.
emptyFunction
;
option
=
option
||
{};
functions
.
begin
=
function
()
{
// // XXX make revision storage check and repair
// // to enable check/repair sub storage from this storage
// // by calling this function just below
// //functions.repairAllSubStorages();
// // else we assume that sub storages are good
// functions.getAllDocuments(functions.newParam(
// doc,
// option,
// repair
// ));
// };
// functions.repairAllSubStorages = function () {
var
i
;
...
...
@@ -315,8 +318,8 @@
// 1: [responseB, [2]]
],
"
attachments
"
:
{
// attachmentA : {_id: attachmentA, _revs_info, _
mime
type: ..}
// attachmentB : {_id: attachmentB, _revs_info, _
mime
type: ..}
// attachmentA : {_id: attachmentA, _revs_info, _
content_
type: ..}
// attachmentB : {_id: attachmentB, _revs_info, _
content_
type: ..}
}
},
"
conflicts
"
:
{
...
...
@@ -333,9 +336,9 @@
var
i
,
metadata
,
cloned_option
;
metadata
=
priv
.
clone
(
param
.
doc
);
cloned_option
=
priv
.
clone
(
param
.
option
);
option
.
conflicts
=
true
;
option
.
revs
=
true
;
option
.
revs_info
=
true
;
cloned_
option
.
conflicts
=
true
;
cloned_
option
.
revs
=
true
;
cloned_
option
.
revs_info
=
true
;
for
(
i
=
0
;
i
<
priv
.
storage_list
.
length
;
i
+=
1
)
{
// if the document is not loaded
priv
.
send
(
command
,
"
get
"
,
i
,
...
...
@@ -356,7 +359,7 @@
// get document failed, exit
param
.
deal_result_state
=
"
error
"
;
callback
({
"
status
"
:
"
conflict
"
,
"
status
"
:
409
,
"
message
"
:
"
An error occured on the sub storage
"
,
"
reason
"
:
err
.
reason
},
undefined
);
...
...
@@ -378,6 +381,7 @@
// this is now the last response
functions
.
makeResponsesStats
(
param
.
responses
);
//console.log(JSON.parse(JSON.stringify(param.responses)));
if
(
param
.
responses
.
stats_items
.
length
===
1
)
{
// the responses are equals!
response_object
.
ok
=
true
;
...
...
@@ -394,7 +398,7 @@
if
(
param
.
repair
===
false
)
{
// do not repair
callback
({
"
status
"
:
"
conflict
"
,
"
status
"
:
409
,
"
message
"
:
"
Some documents are different in the sub storages
"
,
"
reason
"
:
"
Storage contents differ
"
},
undefined
);
...
...
@@ -460,7 +464,7 @@
/*jslint unparam: true */
if
(
err
)
{
callback
({
"
status
"
:
"
conflict
"
,
"
status
"
:
409
,
"
message
"
:
"
Unable to retreive attachments
"
,
"
reason
"
:
err
.
reason
},
undefined
);
...
...
@@ -513,7 +517,7 @@
if
(
new_doc
.
_attachments
.
hasOwnProperty
(
i
))
{
attachment_to_put
.
push
({
"
_id
"
:
i
,
"
_
mime
type
"
:
new_doc
.
_attachments
[
i
].
content_type
,
"
_
content_
type
"
:
new_doc
.
_attachments
[
i
].
content_type
,
"
_revs_info
"
:
new_doc
.
_revs_info
});
}
...
...
@@ -555,9 +559,7 @@
var
i
,
attachment
;
if
(
err
)
{
return
callback
({
"
status
"
:
40
,
"
statusText
"
:
"
Check Failed
"
,
"
error
"
:
"
check_failed
"
,
"
status
"
:
409
,
"
message
"
:
"
Unable to copy attachments
"
,
"
reason
"
:
err
.
reason
},
undefined
);
...
...
@@ -566,7 +568,7 @@
attachment
=
{
"
_id
"
:
param
.
doc
.
_id
,
"
_attachment
"
:
attachment_to_put
[
i
].
_id
,
"
_
mimetype
"
:
attachment_to_put
[
i
].
_mime
type
,
"
_
content_type
"
:
attachment_to_put
[
i
].
_content_
type
,
"
_revs_info
"
:
attachment_to_put
[
i
].
_revs_info
,
// "_revs_info": param.responses.list[index]._revs_info,
"
_data
"
:
param
.
responses
.
attachments
[
attachment_to_put
[
i
].
_id
]
...
...
@@ -640,7 +642,7 @@
* @param {object} command The JIO command
*/
that
.
post
=
function
(
command
,
metadata
,
option
)
{
that
.
genericRequest
(
command
,
"
p
u
t
"
,
metadata
,
option
);
that
.
genericRequest
(
command
,
"
p
os
t
"
,
metadata
,
option
);
};
/**
...
...
@@ -649,7 +651,7 @@
* @param {object} command The JIO command
*/
that
.
put
=
function
(
command
,
metadata
,
option
)
{
that
.
genericRequest
(
command
,
"
p
os
t
"
,
metadata
,
option
);
that
.
genericRequest
(
command
,
"
p
u
t
"
,
metadata
,
option
);
};
/**
...
...
@@ -696,7 +698,5 @@
that
.
removeAttachment
=
function
(
command
,
param
,
option
)
{
that
.
genericRequest
(
command
,
"
removeAttachment
"
,
param
,
option
);
};
return
that
;
});
}));
test/jio.storage/replicaterevisionstorage.tests.js
View file @
f2943ed8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment