Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Hardik Juneja
jio-main
Commits
e7f70409
Commit
e7f70409
authored
Jul 22, 2016
by
Aurel
Committed by
Cédric Le Ninivin
Jul 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replicate : when getting a conflict, always use put method on creation
/reviewed-on
!28
parent
e0f00ad7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
196 additions
and
1 deletion
+196
-1
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+1
-1
test/jio.storage/replicatestorage.tests.js
test/jio.storage/replicatestorage.tests.js
+195
-0
No files found.
src/jio.storage/replicatestorage.js
View file @
e7f70409
...
...
@@ -235,7 +235,7 @@
}
if
(
options
.
conflict_force
===
true
)
{
return
propagateModification
(
source
,
destination
,
doc
,
local_hash
,
id
,
options
);
id
);
}
// Already exists on destination
throw
new
jIO
.
util
.
jIOError
(
"
Conflict on '
"
+
id
+
"
':
"
+
...
...
test/jio.storage/replicatestorage.tests.js
View file @
e7f70409
...
...
@@ -939,6 +939,71 @@
});
});
test
(
"
local and remote document creations: keep local, remote post
"
,
function
()
{
stop
();
expect
(
3
);
var
context
=
this
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
use_remote_post
:
1
,
local_sub_storage
:
{
type
:
"
uuid
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
remote_sub_storage
:
{
type
:
"
uuid
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
conflict_handling
:
1
});
RSVP
.
all
([
context
.
jio
.
put
(
"
conflict
"
,
{
"
title
"
:
"
foo
"
}),
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
:
"
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 remote
"
,
function
()
{
stop
();
expect
(
3
);
...
...
@@ -1002,6 +1067,71 @@
});
});
test
(
"
local and remote document creations: keep remote, remote post
"
,
function
()
{
stop
();
expect
(
3
);
var
context
=
this
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
use_remote_post
:
1
,
local_sub_storage
:
{
type
:
"
uuid
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
remote_sub_storage
:
{
type
:
"
uuid
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
conflict_handling
:
2
});
RSVP
.
all
([
context
.
jio
.
put
(
"
conflict
"
,
{
"
title
"
:
"
foo
"
}),
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
);
...
...
@@ -1065,6 +1195,71 @@
});
});
test
(
"
local and remote document creations: continue, remote post
"
,
function
()
{
stop
();
expect
(
4
);
var
context
=
this
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
use_remote_post
:
1
,
local_sub_storage
:
{
type
:
"
uuid
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
remote_sub_storage
:
{
type
:
"
uuid
"
,
sub_storage
:
{
type
:
"
memory
"
}
},
conflict_handling
:
3
});
RSVP
.
all
([
context
.
jio
.
put
(
"
conflict
"
,
{
"
title
"
:
"
foo
"
}),
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
"
);
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
// equal(error.message, "Cannot find document: conflict");
equal
(
error
.
status_code
,
404
);
})
.
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
:
"
bar
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
local and remote same document creations
"
,
function
()
{
stop
();
expect
(
1
);
...
...
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