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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
jio
Commits
533256d0
Commit
533256d0
authored
Jul 22, 2016
by
Aurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replicate : when getting a conflict, always use put method
parent
e0f00ad7
Changes
2
Show 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 @
533256d0
...
@@ -235,7 +235,7 @@
...
@@ -235,7 +235,7 @@
}
}
if
(
options
.
conflict_force
===
true
)
{
if
(
options
.
conflict_force
===
true
)
{
return
propagateModification
(
source
,
destination
,
doc
,
local_hash
,
return
propagateModification
(
source
,
destination
,
doc
,
local_hash
,
id
,
options
);
id
);
}
}
// Already exists on destination
// Already exists on destination
throw
new
jIO
.
util
.
jIOError
(
"
Conflict on '
"
+
id
+
"
':
"
+
throw
new
jIO
.
util
.
jIOError
(
"
Conflict on '
"
+
id
+
"
':
"
+
...
...
test/jio.storage/replicatestorage.tests.js
View file @
533256d0
...
@@ -939,6 +939,71 @@
...
@@ -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
()
{
test
(
"
local and remote document creations: keep remote
"
,
function
()
{
stop
();
stop
();
expect
(
3
);
expect
(
3
);
...
@@ -1002,6 +1067,71 @@
...
@@ -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
()
{
test
(
"
local and remote document creations: continue
"
,
function
()
{
stop
();
stop
();
expect
(
4
);
expect
(
4
);
...
@@ -1065,6 +1195,71 @@
...
@@ -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
()
{
test
(
"
local and remote same document creations
"
,
function
()
{
stop
();
stop
();
expect
(
1
);
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