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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
jio
Commits
1da27f36
Commit
1da27f36
authored
Sep 27, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[replicatestorage] Always skip document if checked once
parent
4dd17986
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
42 deletions
+16
-42
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+16
-42
No files found.
src/jio.storage/replicatestorage.js
View file @
1da27f36
...
@@ -275,19 +275,16 @@
...
@@ -275,19 +275,16 @@
});
});
}
}
function
propagateAttachmentDeletion
(
context
,
skip_attachment_dict
,
function
propagateAttachmentDeletion
(
context
,
destination
,
destination
,
id
,
name
)
{
id
,
name
)
{
return
destination
.
removeAttachment
(
id
,
name
)
return
destination
.
removeAttachment
(
id
,
name
)
.
push
(
function
()
{
.
push
(
function
()
{
return
context
.
_signature_sub_storage
.
removeAttachment
(
id
,
name
);
return
context
.
_signature_sub_storage
.
removeAttachment
(
id
,
name
);
})
.
push
(
function
()
{
skip_attachment_dict
[
name
]
=
null
;
});
});
}
}
function
propagateAttachmentModification
(
context
,
skip_attachment_dict
,
function
propagateAttachmentModification
(
context
,
destination
,
destination
,
blob
,
hash
,
id
,
name
)
{
blob
,
hash
,
id
,
name
)
{
return
destination
.
putAttachment
(
id
,
name
,
blob
)
return
destination
.
putAttachment
(
id
,
name
,
blob
)
...
@@ -296,9 +293,6 @@
...
@@ -296,9 +293,6 @@
JSON
.
stringify
({
JSON
.
stringify
({
hash
:
hash
hash
:
hash
}));
}));
})
.
push
(
function
()
{
skip_attachment_dict
[
name
]
=
null
;
});
});
}
}
...
@@ -308,6 +302,8 @@
...
@@ -308,6 +302,8 @@
source
,
destination
,
id
,
name
,
source
,
destination
,
id
,
name
,
conflict_force
,
conflict_revert
,
conflict_force
,
conflict_revert
,
conflict_ignore
)
{
conflict_ignore
)
{
// No need to check twice
skip_attachment_dict
[
name
]
=
null
;
var
remote_blob
;
var
remote_blob
;
return
destination
.
getAttachment
(
id
,
name
)
return
destination
.
getAttachment
(
id
,
name
)
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
...
@@ -331,31 +327,24 @@
...
@@ -331,31 +327,24 @@
// Same modifications on both side
// Same modifications on both side
if
(
local_hash
===
null
)
{
if
(
local_hash
===
null
)
{
// Deleted on both side, drop signature
// Deleted on both side, drop signature
return
context
.
_signature_sub_storage
.
removeAttachment
(
id
,
name
)
return
context
.
_signature_sub_storage
.
removeAttachment
(
id
,
name
);
.
push
(
function
()
{
skip_attachment_dict
[
name
]
=
null
;
});
}
}
return
context
.
_signature_sub_storage
.
putAttachment
(
id
,
name
,
return
context
.
_signature_sub_storage
.
putAttachment
(
id
,
name
,
JSON
.
stringify
({
JSON
.
stringify
({
hash
:
local_hash
hash
:
local_hash
}))
}));
.
push
(
function
()
{
skip_attachment_dict
[
name
]
=
null
;
});
}
}
if
((
remote_hash
===
status_hash
)
||
(
conflict_force
===
true
))
{
if
((
remote_hash
===
status_hash
)
||
(
conflict_force
===
true
))
{
// Modified only locally. No conflict or force
// Modified only locally. No conflict or force
if
(
local_hash
===
null
)
{
if
(
local_hash
===
null
)
{
// Deleted locally
// Deleted locally
return
propagateAttachmentDeletion
(
context
,
skip_attachment_dict
,
return
propagateAttachmentDeletion
(
context
,
destination
,
destination
,
id
,
name
);
id
,
name
);
}
}
return
propagateAttachmentModification
(
context
,
return
propagateAttachmentModification
(
context
,
skip_attachment_dict
,
destination
,
blob
,
destination
,
blob
,
local_hash
,
id
,
name
);
local_hash
,
id
,
name
);
}
}
...
@@ -369,12 +358,11 @@
...
@@ -369,12 +358,11 @@
// Automatically resolve conflict or force revert
// Automatically resolve conflict or force revert
if
(
remote_hash
===
null
)
{
if
(
remote_hash
===
null
)
{
// Deleted remotely
// Deleted remotely
return
propagateAttachmentDeletion
(
context
,
skip_attachment_dict
,
return
propagateAttachmentDeletion
(
context
,
source
,
id
,
name
);
source
,
id
,
name
);
}
}
return
propagateAttachmentModification
(
return
propagateAttachmentModification
(
context
,
context
,
skip_attachment_dict
,
source
,
source
,
remote_blob
,
remote_blob
,
remote_hash
,
remote_hash
,
...
@@ -387,7 +375,6 @@
...
@@ -387,7 +375,6 @@
if
(
remote_hash
===
null
)
{
if
(
remote_hash
===
null
)
{
// Copy remote modification remotely
// Copy remote modification remotely
return
propagateAttachmentModification
(
context
,
return
propagateAttachmentModification
(
context
,
skip_attachment_dict
,
destination
,
blob
,
destination
,
blob
,
local_hash
,
id
,
name
);
local_hash
,
id
,
name
);
}
}
...
@@ -824,7 +811,6 @@
...
@@ -824,7 +811,6 @@
options
)
{
options
)
{
var
result
=
new
RSVP
.
Queue
(),
var
result
=
new
RSVP
.
Queue
(),
post_id
,
post_id
,
to_skip
=
true
,
from_local
;
from_local
;
if
(
options
===
undefined
)
{
if
(
options
===
undefined
)
{
options
=
{};
options
=
{};
...
@@ -852,7 +838,6 @@
...
@@ -852,7 +838,6 @@
return
destination
.
post
(
doc
);
return
destination
.
post
(
doc
);
})
})
.
push
(
function
(
new_id
)
{
.
push
(
function
(
new_id
)
{
to_skip
=
false
;
post_id
=
new_id
;
post_id
=
new_id
;
return
source
.
put
(
post_id
,
doc
);
return
source
.
put
(
post_id
,
doc
);
})
})
...
@@ -890,7 +875,6 @@
...
@@ -890,7 +875,6 @@
return
context
.
_signature_sub_storage
.
remove
(
id
);
return
context
.
_signature_sub_storage
.
remove
(
id
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
to_skip
=
true
;
return
context
.
_signature_sub_storage
.
put
(
post_id
,
{
return
context
.
_signature_sub_storage
.
put
(
post_id
,
{
hash
:
hash
,
hash
:
hash
,
from_local
:
from_local
from_local
:
from_local
...
@@ -920,11 +904,6 @@
...
@@ -920,11 +904,6 @@
});
});
}
}
return
result
return
result
.
push
(
function
()
{
if
(
to_skip
)
{
skip_document_dict
[
id
]
=
null
;
}
})
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
if
(
error
instanceof
SkipError
)
{
if
(
error
instanceof
SkipError
)
{
return
;
return
;
...
@@ -933,7 +912,7 @@
...
@@ -933,7 +912,7 @@
});
});
}
}
function
propagateDeletion
(
context
,
destination
,
id
,
skip_document_dict
,
function
propagateDeletion
(
context
,
destination
,
id
,
skip_deleted_document_dict
)
{
skip_deleted_document_dict
)
{
// Do not delete a document if it has an attachment
// Do not delete a document if it has an attachment
// ie, replication should prevent losing user data
// ie, replication should prevent losing user data
...
@@ -967,7 +946,6 @@
...
@@ -967,7 +946,6 @@
}
}
return
result
return
result
.
push
(
function
()
{
.
push
(
function
()
{
skip_document_dict
[
id
]
=
null
;
// No need to sync attachment twice on this document
// No need to sync attachment twice on this document
skip_deleted_document_dict
[
id
]
=
null
;
skip_deleted_document_dict
[
id
]
=
null
;
});
});
...
@@ -981,6 +959,8 @@
...
@@ -981,6 +959,8 @@
conflict_force
,
conflict_revert
,
conflict_force
,
conflict_revert
,
conflict_ignore
,
conflict_ignore
,
options
)
{
options
)
{
// No need to check twice
skip_document_dict
[
id
]
=
null
;
var
from_local
=
options
.
from_local
;
var
from_local
=
options
.
from_local
;
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
...
@@ -1013,19 +993,13 @@
...
@@ -1013,19 +993,13 @@
// Same modifications on both side
// Same modifications on both side
if
(
local_hash
===
null
)
{
if
(
local_hash
===
null
)
{
// Deleted on both side, drop signature
// Deleted on both side, drop signature
return
context
.
_signature_sub_storage
.
remove
(
id
)
return
context
.
_signature_sub_storage
.
remove
(
id
);
.
push
(
function
()
{
skip_document_dict
[
id
]
=
null
;
});
}
}
return
context
.
_signature_sub_storage
.
put
(
id
,
{
return
context
.
_signature_sub_storage
.
put
(
id
,
{
hash
:
local_hash
,
hash
:
local_hash
,
from_local
:
from_local
from_local
:
from_local
})
});
.
push
(
function
()
{
skip_document_dict
[
id
]
=
null
;
});
}
}
if
((
remote_hash
===
status_hash
)
||
(
conflict_force
===
true
))
{
if
((
remote_hash
===
status_hash
)
||
(
conflict_force
===
true
))
{
...
@@ -1033,7 +1007,6 @@
...
@@ -1033,7 +1007,6 @@
if
(
local_hash
===
null
)
{
if
(
local_hash
===
null
)
{
// Deleted locally
// Deleted locally
return
propagateDeletion
(
context
,
destination
,
id
,
return
propagateDeletion
(
context
,
destination
,
id
,
skip_document_dict
,
skip_deleted_document_dict
);
skip_deleted_document_dict
);
}
}
return
propagateModification
(
context
,
source
,
destination
,
doc
,
return
propagateModification
(
context
,
source
,
destination
,
doc
,
...
@@ -1057,7 +1030,7 @@
...
@@ -1057,7 +1030,7 @@
// Automatically resolve conflict or force revert
// Automatically resolve conflict or force revert
if
(
remote_hash
===
null
)
{
if
(
remote_hash
===
null
)
{
// Deleted remotely
// Deleted remotely
return
propagateDeletion
(
context
,
source
,
id
,
skip_document_dict
,
return
propagateDeletion
(
context
,
source
,
id
,
skip_deleted_document_dict
);
skip_deleted_document_dict
);
}
}
return
propagateModification
(
return
propagateModification
(
...
@@ -1159,7 +1132,8 @@
...
@@ -1159,7 +1132,8 @@
function
pushStorage
(
context
,
skip_document_dict
,
function
pushStorage
(
context
,
skip_document_dict
,
skip_deleted_document_dict
,
skip_deleted_document_dict
,
cache
,
source_key
,
destination_key
,
cache
,
source_key
,
destination_key
,
source
,
destination
,
signature_allDocs
,
options
)
{
source
,
destination
,
signature_allDocs
,
options
)
{
var
argument_list
=
[],
var
argument_list
=
[],
argument_list_deletion
=
[];
argument_list_deletion
=
[];
if
(
!
options
.
hasOwnProperty
(
"
use_post
"
))
{
if
(
!
options
.
hasOwnProperty
(
"
use_post
"
))
{
...
...
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