Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
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
Hide 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 @@
...
@@ -22,7 +22,7 @@
module
(
jIO
);
module
(
jIO
);
}([
'
jio
'
],
function
(
jIO
)
{
}([
'
jio
'
],
function
(
jIO
)
{
"
use strict
"
;
"
use strict
"
;
jIO
.
addStorage
Type
(
'
replicaterevision
'
,
function
(
spec
)
{
jIO
.
addStorage
(
'
replicaterevision
'
,
function
(
spec
)
{
var
that
=
this
,
priv
=
{};
var
that
=
this
,
priv
=
{};
spec
=
spec
||
{};
spec
=
spec
||
{};
...
@@ -217,16 +217,9 @@
...
@@ -217,16 +217,9 @@
command
.
success
();
command
.
success
();
}
}
if
(
!
param
.
_id
)
{
if
(
!
param
.
_id
)
{
return
callback
({
return
callback
({
"
status
"
:
501
});
"
status
"
:
501
});
}
}
priv
.
check
(
priv
.
check
(
command
,
param
,
option
,
callback
);
command
,
param
,
option
,
callback
);
};
};
/**
/**
...
@@ -264,8 +257,18 @@
...
@@ -264,8 +257,18 @@
callback
=
callback
||
priv
.
emptyFunction
;
callback
=
callback
||
priv
.
emptyFunction
;
option
=
option
||
{};
option
=
option
||
{};
functions
.
begin
=
function
()
{
functions
.
begin
=
function
()
{
// };
// // XXX make revision storage check and repair
// functions.repairAllSubStorages = function () {
// // 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
;
var
i
;
for
(
i
=
0
;
i
<
priv
.
storage_list
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
priv
.
storage_list
.
length
;
i
+=
1
)
{
priv
.
send
(
priv
.
send
(
...
@@ -315,8 +318,8 @@
...
@@ -315,8 +318,8 @@
// 1: [responseB, [2]]
// 1: [responseB, [2]]
],
],
"
attachments
"
:
{
"
attachments
"
:
{
// attachmentA : {_id: attachmentA, _revs_info, _
mime
type: ..}
// attachmentA : {_id: attachmentA, _revs_info, _
content_
type: ..}
// attachmentB : {_id: attachmentB, _revs_info, _
mime
type: ..}
// attachmentB : {_id: attachmentB, _revs_info, _
content_
type: ..}
}
}
},
},
"
conflicts
"
:
{
"
conflicts
"
:
{
...
@@ -333,9 +336,9 @@
...
@@ -333,9 +336,9 @@
var
i
,
metadata
,
cloned_option
;
var
i
,
metadata
,
cloned_option
;
metadata
=
priv
.
clone
(
param
.
doc
);
metadata
=
priv
.
clone
(
param
.
doc
);
cloned_option
=
priv
.
clone
(
param
.
option
);
cloned_option
=
priv
.
clone
(
param
.
option
);
option
.
conflicts
=
true
;
cloned_
option
.
conflicts
=
true
;
option
.
revs
=
true
;
cloned_
option
.
revs
=
true
;
option
.
revs_info
=
true
;
cloned_
option
.
revs_info
=
true
;
for
(
i
=
0
;
i
<
priv
.
storage_list
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
priv
.
storage_list
.
length
;
i
+=
1
)
{
// if the document is not loaded
// if the document is not loaded
priv
.
send
(
command
,
"
get
"
,
i
,
priv
.
send
(
command
,
"
get
"
,
i
,
...
@@ -356,7 +359,7 @@
...
@@ -356,7 +359,7 @@
// get document failed, exit
// get document failed, exit
param
.
deal_result_state
=
"
error
"
;
param
.
deal_result_state
=
"
error
"
;
callback
({
callback
({
"
status
"
:
"
conflict
"
,
"
status
"
:
409
,
"
message
"
:
"
An error occured on the sub storage
"
,
"
message
"
:
"
An error occured on the sub storage
"
,
"
reason
"
:
err
.
reason
"
reason
"
:
err
.
reason
},
undefined
);
},
undefined
);
...
@@ -378,6 +381,7 @@
...
@@ -378,6 +381,7 @@
// this is now the last response
// this is now the last response
functions
.
makeResponsesStats
(
param
.
responses
);
functions
.
makeResponsesStats
(
param
.
responses
);
//console.log(JSON.parse(JSON.stringify(param.responses)));
if
(
param
.
responses
.
stats_items
.
length
===
1
)
{
if
(
param
.
responses
.
stats_items
.
length
===
1
)
{
// the responses are equals!
// the responses are equals!
response_object
.
ok
=
true
;
response_object
.
ok
=
true
;
...
@@ -394,7 +398,7 @@
...
@@ -394,7 +398,7 @@
if
(
param
.
repair
===
false
)
{
if
(
param
.
repair
===
false
)
{
// do not repair
// do not repair
callback
({
callback
({
"
status
"
:
"
conflict
"
,
"
status
"
:
409
,
"
message
"
:
"
Some documents are different in the sub storages
"
,
"
message
"
:
"
Some documents are different in the sub storages
"
,
"
reason
"
:
"
Storage contents differ
"
"
reason
"
:
"
Storage contents differ
"
},
undefined
);
},
undefined
);
...
@@ -460,7 +464,7 @@
...
@@ -460,7 +464,7 @@
/*jslint unparam: true */
/*jslint unparam: true */
if
(
err
)
{
if
(
err
)
{
callback
({
callback
({
"
status
"
:
"
conflict
"
,
"
status
"
:
409
,
"
message
"
:
"
Unable to retreive attachments
"
,
"
message
"
:
"
Unable to retreive attachments
"
,
"
reason
"
:
err
.
reason
"
reason
"
:
err
.
reason
},
undefined
);
},
undefined
);
...
@@ -513,7 +517,7 @@
...
@@ -513,7 +517,7 @@
if
(
new_doc
.
_attachments
.
hasOwnProperty
(
i
))
{
if
(
new_doc
.
_attachments
.
hasOwnProperty
(
i
))
{
attachment_to_put
.
push
({
attachment_to_put
.
push
({
"
_id
"
:
i
,
"
_id
"
:
i
,
"
_
mime
type
"
:
new_doc
.
_attachments
[
i
].
content_type
,
"
_
content_
type
"
:
new_doc
.
_attachments
[
i
].
content_type
,
"
_revs_info
"
:
new_doc
.
_revs_info
"
_revs_info
"
:
new_doc
.
_revs_info
});
});
}
}
...
@@ -555,9 +559,7 @@
...
@@ -555,9 +559,7 @@
var
i
,
attachment
;
var
i
,
attachment
;
if
(
err
)
{
if
(
err
)
{
return
callback
({
return
callback
({
"
status
"
:
40
,
"
status
"
:
409
,
"
statusText
"
:
"
Check Failed
"
,
"
error
"
:
"
check_failed
"
,
"
message
"
:
"
Unable to copy attachments
"
,
"
message
"
:
"
Unable to copy attachments
"
,
"
reason
"
:
err
.
reason
"
reason
"
:
err
.
reason
},
undefined
);
},
undefined
);
...
@@ -566,7 +568,7 @@
...
@@ -566,7 +568,7 @@
attachment
=
{
attachment
=
{
"
_id
"
:
param
.
doc
.
_id
,
"
_id
"
:
param
.
doc
.
_id
,
"
_attachment
"
:
attachment_to_put
[
i
].
_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
"
:
attachment_to_put
[
i
].
_revs_info
,
// "_revs_info": param.responses.list[index]._revs_info,
// "_revs_info": param.responses.list[index]._revs_info,
"
_data
"
:
param
.
responses
.
attachments
[
attachment_to_put
[
i
].
_id
]
"
_data
"
:
param
.
responses
.
attachments
[
attachment_to_put
[
i
].
_id
]
...
@@ -640,7 +642,7 @@
...
@@ -640,7 +642,7 @@
* @param {object} command The JIO command
* @param {object} command The JIO command
*/
*/
that
.
post
=
function
(
command
,
metadata
,
option
)
{
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 @@
...
@@ -649,7 +651,7 @@
* @param {object} command The JIO command
* @param {object} command The JIO command
*/
*/
that
.
put
=
function
(
command
,
metadata
,
option
)
{
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 @@
...
@@ -696,7 +698,5 @@
that
.
removeAttachment
=
function
(
command
,
param
,
option
)
{
that
.
removeAttachment
=
function
(
command
,
param
,
option
)
{
that
.
genericRequest
(
command
,
"
removeAttachment
"
,
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