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
84cba972
Commit
84cba972
authored
May 05, 2017
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReplicateStorage: fetch signature hash with allDocs only
parent
7e1935d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
39 deletions
+69
-39
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+33
-34
test/jio.storage/replicatestorage.tests.js
test/jio.storage/replicatestorage.tests.js
+36
-5
No files found.
src/jio.storage/replicatestorage.js
View file @
84cba972
...
...
@@ -56,9 +56,12 @@
stringify
(
this
.
_query_options
)
);
this
.
_signature_sub_storage
=
jIO
.
createJIO
({
type
:
"
document
"
,
document_id
:
this
.
_signature_hash
,
sub_storage
:
spec
.
signature_storage
||
spec
.
local_sub_storage
type
:
"
query
"
,
sub_storage
:
{
type
:
"
document
"
,
document_id
:
this
.
_signature_hash
,
sub_storage
:
spec
.
signature_storage
||
spec
.
local_sub_storage
}
});
this
.
_use_remote_post
=
spec
.
use_remote_post
||
false
;
...
...
@@ -805,31 +808,14 @@
source
,
destination
,
id
,
conflict_force
,
conflict_revert
,
conflict_ignore
,
is_creation
,
is_modification
,
status_hash
,
getMethod
,
options
)
{
queue
.
push
(
function
()
{
// Optimisation to save a get call to signature storage
if
(
is_creation
===
true
)
{
return
RSVP
.
all
([
getMethod
(
id
),
{
hash
:
null
}
]);
}
if
(
is_modification
===
true
)
{
return
RSVP
.
all
([
getMethod
(
id
),
context
.
_signature_sub_storage
.
get
(
id
)
]);
}
throw
new
jIO
.
util
.
jIOError
(
"
Unexpected call of
"
+
"
checkSignatureDifference
"
,
409
);
return
getMethod
(
id
);
})
.
push
(
function
(
result_list
)
{
var
doc
=
result_list
[
0
],
local_hash
=
generateHash
(
stringify
(
doc
)),
status_hash
=
result_list
[
1
].
hash
;
.
push
(
function
(
doc
)
{
var
local_hash
=
generateHash
(
stringify
(
doc
));
if
(
local_hash
!==
status_hash
)
{
return
checkAndPropagate
(
context
,
skip_document_dict
,
...
...
@@ -859,6 +845,7 @@
signature_dict
=
{},
is_modification
,
is_creation
,
status_hash
,
key
,
queue
=
new
RSVP
.
Queue
();
for
(
i
=
0
;
i
<
source_allDocs
.
data
.
total_rows
;
i
+=
1
)
{
...
...
@@ -872,7 +859,8 @@
if
(
!
skip_document_dict
.
hasOwnProperty
(
signature_allDocs
.
data
.
rows
[
i
].
id
))
{
signature_dict
[
signature_allDocs
.
data
.
rows
[
i
].
id
]
=
i
;
signature_dict
[
signature_allDocs
.
data
.
rows
[
i
].
id
]
=
signature_allDocs
.
data
.
rows
[
i
].
value
.
hash
;
}
}
for
(
key
in
local_dict
)
{
...
...
@@ -881,6 +869,13 @@
&&
options
.
check_modification
;
is_creation
=
!
signature_dict
.
hasOwnProperty
(
key
)
&&
options
.
check_creation
;
if
(
is_creation
===
true
)
{
status_hash
=
null
;
}
else
if
(
is_modification
===
true
)
{
status_hash
=
signature_dict
[
key
];
}
if
(
is_modification
===
true
||
is_creation
===
true
)
{
argument_list
.
push
([
undefined
,
context
,
skip_document_dict
,
source
,
destination
,
...
...
@@ -888,7 +883,7 @@
options
.
conflict_force
,
options
.
conflict_revert
,
options
.
conflict_ignore
,
is_creation
,
is_modification
,
status_hash
,
source
.
get
.
bind
(
source
),
options
]);
}
...
...
@@ -949,17 +944,19 @@
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
// Ensure that the document storage is usable
return
context
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
get
(
context
.
_signature_hash
);
return
context
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__storage
.
_sub_storage
.
get
(
context
.
_signature_hash
);
})
.
push
(
undefined
,
function
(
error
)
{
if
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
404
))
{
return
context
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
put
(
context
.
_signature_hash
,
{}
);
return
context
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__storage
.
_sub_storage
.
put
(
context
.
_signature_hash
,
{}
);
}
throw
error
;
})
...
...
@@ -989,7 +986,9 @@
context
.
_check_remote_modification
||
context
.
_check_remote_creation
||
context
.
_check_remote_deletion
)
{
return
context
.
_signature_sub_storage
.
allDocs
();
return
context
.
_signature_sub_storage
.
allDocs
({
select_list
:
[
'
hash
'
]
});
}
})
...
...
test/jio.storage/replicatestorage.tests.js
View file @
84cba972
...
...
@@ -111,14 +111,25 @@
"
_replicate_7209dfbcaff00f6637f939fdd71fa896793ed385
"
);
ok
(
jio
.
__storage
.
_signature_sub_storage
instanceof
jio
.
constructor
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__type
,
"
document
"
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__type
,
"
query
"
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_document_id
,
ok
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
instanceof
jio
.
constructor
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__type
,
"
document
"
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__storage
.
_document_id
,
jio
.
__storage
.
_signature_hash
);
ok
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
ok
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__storage
.
_sub_storage
instanceof
jio
.
constructor
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__type
,
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__storage
.
_sub_storage
.
__type
,
"
replicatestorage200
"
);
});
...
...
@@ -175,8 +186,28 @@
equal
(
jio
.
__storage
.
_check_remote_attachment_deletion
,
true
);
equal
(
jio
.
__storage
.
_check_remote_attachment_modification
,
true
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__type
,
ok
(
jio
.
__storage
.
_signature_sub_storage
instanceof
jio
.
constructor
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__type
,
"
query
"
);
ok
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
instanceof
jio
.
constructor
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__type
,
"
document
"
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__storage
.
_document_id
,
jio
.
__storage
.
_signature_hash
);
ok
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__storage
.
_sub_storage
instanceof
jio
.
constructor
);
equal
(
jio
.
__storage
.
_signature_sub_storage
.
__storage
.
_sub_storage
.
__storage
.
_sub_storage
.
__type
,
"
signaturestorage2713
"
);
equal
(
jio
.
__storage
.
_signature_hash
,
"
_replicate_11881e431308c0ec8c0e6430be98db380e1b92f8
"
);
});
...
...
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