Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
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
Alexandra Rogova
jio_mebibou
Commits
ab653402
Commit
ab653402
authored
Jan 06, 2017
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ReplicateStorage: fix unexpected error occuring in case of document not matching the query
parent
55c1be2e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
286 additions
and
8 deletions
+286
-8
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+20
-8
test/jio.storage/replicatestorage.tests.js
test/jio.storage/replicatestorage.tests.js
+266
-0
No files found.
src/jio.storage/replicatestorage.js
View file @
ab653402
...
...
@@ -227,7 +227,8 @@
}
function
checkSignatureDifference
(
queue
,
source
,
destination
,
id
,
conflict_force
,
conflict_ignore
,
conflict_force
,
conflict_revert
,
conflict_ignore
,
is_creation
,
is_modification
,
getMethod
,
options
)
{
queue
...
...
@@ -273,7 +274,12 @@
if
(
conflict_ignore
===
true
)
{
return
;
}
if
(
conflict_force
!==
true
)
{
if
(
conflict_revert
===
true
)
{
return
propagateModification
(
destination
,
source
,
remote_doc
,
remote_hash
,
id
);
}
if
(
conflict_force
===
false
)
{
throw
new
jIO
.
util
.
jIOError
(
"
Conflict on '
"
+
id
+
"
':
"
+
stringify
(
doc
)
+
"
!==
"
+
stringify
(
remote_doc
),
...
...
@@ -307,7 +313,8 @@
function
checkBulkSignatureDifference
(
queue
,
source
,
destination
,
id_list
,
document_status_list
,
options
,
conflict_force
,
conflict_ignore
)
{
conflict_force
,
conflict_revert
,
conflict_ignore
)
{
queue
.
push
(
function
()
{
return
source
.
bulk
(
id_list
);
...
...
@@ -328,7 +335,8 @@
for
(
i
=
0
;
i
<
result_list
.
length
;
i
+=
1
)
{
checkSignatureDifference
(
sub_queue
,
source
,
destination
,
id_list
[
i
].
parameter_list
[
0
],
conflict_force
,
conflict_ignore
,
conflict_force
,
conflict_revert
,
conflict_ignore
,
document_status_list
[
i
].
is_creation
,
document_status_list
[
i
].
is_modification
,
getResult
(
i
),
options
);
...
...
@@ -391,6 +399,7 @@
}
else
{
checkSignatureDifference
(
queue
,
source
,
destination
,
key
,
options
.
conflict_force
,
options
.
conflict_revert
,
options
.
conflict_ignore
,
is_creation
,
is_modification
,
source
.
get
.
bind
(
source
),
...
...
@@ -413,6 +422,7 @@
document_list
,
document_status_list
,
options
,
options
.
conflict_force
,
options
.
conflict_revert
,
options
.
conflict_ignore
);
}
});
...
...
@@ -464,10 +474,10 @@
use_post
:
context
.
_use_remote_post
,
conflict_force
:
(
context
.
_conflict_handling
===
CONFLICT_KEEP_LOCAL
),
conflict_
ignore
:
(
(
context
.
_conflict_handling
===
CONFLICT_CONTINUE
)
||
(
context
.
_conflict_handling
===
CONFLICT_KEEP_REMOTE
)
),
conflict_
revert
:
(
context
.
_conflict_handling
===
CONFLICT_KEEP_REMOTE
),
conflict_ignore
:
(
context
.
_conflict_handling
===
CONFLICT_CONTINUE
),
check_modification
:
context
.
_check_local_modification
,
check_creation
:
context
.
_check_local_creation
,
check_deletion
:
context
.
_check_local_deletion
...
...
@@ -494,6 +504,8 @@
use_bulk_get
:
use_bulk_get
,
conflict_force
:
(
context
.
_conflict_handling
===
CONFLICT_KEEP_REMOTE
),
conflict_revert
:
(
context
.
_conflict_handling
===
CONFLICT_KEEP_LOCAL
),
conflict_ignore
:
(
context
.
_conflict_handling
===
CONFLICT_CONTINUE
),
check_modification
:
context
.
_check_remote_modification
,
...
...
test/jio.storage/replicatestorage.tests.js
View file @
ab653402
...
...
@@ -1014,6 +1014,139 @@
});
});
test
(
"
local and remote document creations: keep local,
"
+
"
local not matching query
"
,
function
()
{
stop
();
expect
(
3
);
var
context
=
this
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
local_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
remote_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
query
:
{
query
:
'
type: "foobar"
'
},
conflict_handling
:
1
});
RSVP
.
all
([
context
.
jio
.
put
(
"
conflict
"
,
{
"
title
"
:
"
foo
"
}),
context
.
jio
.
__storage
.
_remote_sub_storage
.
put
(
"
conflict
"
,
{
"
title
"
:
"
bar
"
,
"
type
"
:
"
foobar
"
})
])
.
then
(
function
()
{
return
context
.
jio
.
repair
();
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_signature_sub_storage
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
hash
:
"
5ea9013447539ad65de308cbd75b5826a2ae30e5
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
foo
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_remote_sub_storage
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
foo
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
local and remote document creations: keep local,
"
+
"
remote not matching query
"
,
function
()
{
stop
();
expect
(
3
);
var
context
=
this
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
local_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
remote_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
query
:
{
query
:
'
type: "foobar"
'
},
conflict_handling
:
1
});
RSVP
.
all
([
context
.
jio
.
put
(
"
conflict
"
,
{
"
title
"
:
"
foo
"
,
"
type
"
:
"
foobar
"
}),
context
.
jio
.
__storage
.
_remote_sub_storage
.
put
(
"
conflict
"
,
{
"
title
"
:
"
bar
"
})
])
.
then
(
function
()
{
return
context
.
jio
.
repair
();
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_signature_sub_storage
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
hash
:
"
a0a1b37cee3709101b752c56e59b9d66cce09961
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
foo
"
,
type
:
"
foobar
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_remote_sub_storage
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
foo
"
,
type
:
"
foobar
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
local and remote document creations: keep remote
"
,
function
()
{
stop
();
expect
(
3
);
...
...
@@ -1142,6 +1275,139 @@
});
});
test
(
"
local and remote document creations: keep remote,
"
+
"
local not matching query
"
,
function
()
{
stop
();
expect
(
3
);
var
context
=
this
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
local_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
remote_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
query
:
{
query
:
'
type: "foobar"
'
},
conflict_handling
:
2
});
RSVP
.
all
([
context
.
jio
.
put
(
"
conflict
"
,
{
"
title
"
:
"
foo
"
}),
context
.
jio
.
__storage
.
_remote_sub_storage
.
put
(
"
conflict
"
,
{
"
title
"
:
"
bar
"
,
"
type
"
:
"
foobar
"
})
])
.
then
(
function
()
{
return
context
.
jio
.
repair
();
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_signature_sub_storage
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
hash
:
"
45efa2292d54cc4ce1f726ea197bc0b9721fc1dc
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
bar
"
,
type
:
"
foobar
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_remote_sub_storage
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
bar
"
,
type
:
"
foobar
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
local and remote document creations: keep remote,
"
+
"
remote not matching query
"
,
function
()
{
stop
();
expect
(
3
);
var
context
=
this
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
local_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
remote_sub_storage
:
{
type
:
"
query
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
query
:
{
query
:
'
type: "foobar"
'
},
conflict_handling
:
2
});
RSVP
.
all
([
context
.
jio
.
put
(
"
conflict
"
,
{
"
title
"
:
"
foo
"
,
"
type
"
:
"
foobar
"
}),
context
.
jio
.
__storage
.
_remote_sub_storage
.
put
(
"
conflict
"
,
{
"
title
"
:
"
bar
"
})
])
.
then
(
function
()
{
return
context
.
jio
.
repair
();
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_signature_sub_storage
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
hash
:
"
6799f3ea80e325b89f19589282a343c376c1f1af
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
bar
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_remote_sub_storage
.
get
(
"
conflict
"
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
bar
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
local and remote document creations: continue
"
,
function
()
{
stop
();
expect
(
4
);
...
...
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