Commit c28b6cf6 authored by Romain Courteaud's avatar Romain Courteaud

Release Version 3.19.0

ReplicateStorage: fix some attachment replication issues
parent 3b3ed84b
...@@ -9116,6 +9116,13 @@ return new Parser; ...@@ -9116,6 +9116,13 @@ return new Parser;
}); });
} else { } else {
result result
.push(function () {
// Drop signature if the destination document was empty
// but a signature exists
if (options.create_new_document === true) {
return context._signature_sub_storage.remove(id);
}
})
.push(function () { .push(function () {
return destination.put(id, doc); return destination.put(id, doc);
}) })
...@@ -9229,7 +9236,11 @@ return new Parser; ...@@ -9229,7 +9236,11 @@ return new Parser;
return propagateModification(context, source, destination, doc, return propagateModification(context, source, destination, doc,
local_hash, id, skip_document_dict, local_hash, id, skip_document_dict,
{use_post: ((options.use_post) && {use_post: ((options.use_post) &&
(remote_hash === null))}); (remote_hash === null)),
create_new_document:
((remote_hash === null) &&
(status_hash !== null))
});
} }
// Conflict cases // Conflict cases
...@@ -9252,7 +9263,9 @@ return new Parser; ...@@ -9252,7 +9263,9 @@ return new Parser;
id, id,
skip_document_dict, skip_document_dict,
{use_post: ((options.use_revert_post) && {use_post: ((options.use_revert_post) &&
(local_hash === null))} (local_hash === null)),
create_new_document: ((local_hash === null) &&
(status_hash !== null))}
); );
} }
...@@ -9261,7 +9274,9 @@ return new Parser; ...@@ -9261,7 +9274,9 @@ return new Parser;
// Copy remote modification remotely // Copy remote modification remotely
return propagateModification(context, source, destination, doc, return propagateModification(context, source, destination, doc,
local_hash, id, skip_document_dict, local_hash, id, skip_document_dict,
{use_post: options.use_post}); {use_post: options.use_post,
create_new_document:
(status_hash !== null)});
} }
doc = doc || local_hash; doc = doc || local_hash;
remote_doc = remote_doc || remote_hash; remote_doc = remote_doc || remote_hash;
...@@ -9328,6 +9343,7 @@ return new Parser; ...@@ -9328,6 +9343,7 @@ return new Parser;
} }
function pushStorage(context, skip_document_dict, function pushStorage(context, skip_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 = [],
...@@ -9422,10 +9438,10 @@ return new Parser; ...@@ -9422,10 +9438,10 @@ return new Parser;
options.operation_amount options.operation_amount
); );
}); });
if (options.check_deletion === true) {
for (key in signature_dict) { for (key in signature_dict) {
if (signature_dict.hasOwnProperty(key)) { if (signature_dict.hasOwnProperty(key)) {
if (!local_dict.hasOwnProperty(key)) { if (!local_dict.hasOwnProperty(key)) {
if (options.check_deletion === true) {
argument_list_deletion.push([undefined, argument_list_deletion.push([undefined,
context, context,
skip_document_dict, skip_document_dict,
...@@ -9436,9 +9452,13 @@ return new Parser; ...@@ -9436,9 +9452,13 @@ return new Parser;
options.conflict_revert, options.conflict_revert,
options.conflict_ignore, options.conflict_ignore,
options]); options]);
} else {
skip_deleted_document_dict[key] = null;
} }
} }
} }
}
if (argument_list_deletion.length !== 0) {
queue.push(function () { queue.push(function () {
return dispatchQueue( return dispatchQueue(
context, context,
...@@ -9462,6 +9482,7 @@ return new Parser; ...@@ -9462,6 +9482,7 @@ return new Parser;
var context = this, var context = this,
argument_list = arguments, argument_list = arguments,
skip_document_dict = {}, skip_document_dict = {},
skip_deleted_document_dict = {},
cache = {}; cache = {};
return new RSVP.Queue() return new RSVP.Queue()
...@@ -9525,6 +9546,7 @@ return new Parser; ...@@ -9525,6 +9546,7 @@ return new Parser;
context._check_local_creation || context._check_local_creation ||
context._check_local_deletion) { context._check_local_deletion) {
return pushStorage(context, skip_document_dict, return pushStorage(context, skip_document_dict,
skip_deleted_document_dict,
cache, 'local', 'remote', cache, 'local', 'remote',
context._local_sub_storage, context._local_sub_storage,
context._remote_sub_storage, context._remote_sub_storage,
...@@ -9554,6 +9576,7 @@ return new Parser; ...@@ -9554,6 +9576,7 @@ return new Parser;
context._check_remote_creation || context._check_remote_creation ||
context._check_remote_deletion) { context._check_remote_deletion) {
return pushStorage(context, skip_document_dict, return pushStorage(context, skip_document_dict,
skip_deleted_document_dict,
cache, 'remote', 'local', cache, 'remote', 'local',
context._remote_sub_storage, context._remote_sub_storage,
context._local_sub_storage, context._local_sub_storage,
...@@ -9586,13 +9609,20 @@ return new Parser; ...@@ -9586,13 +9609,20 @@ return new Parser;
.push(function (result) { .push(function (result) {
var i, var i,
local_argument_list = [], local_argument_list = [],
id,
len = result.data.total_rows; len = result.data.total_rows;
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
id = result.data.rows[i].id;
// Do not synchronize attachment if one version of the document
// is deleted but not pushed to the other storage
if (!skip_deleted_document_dict.hasOwnProperty(id) ||
skip_document_dict.hasOwnProperty(id)) {
local_argument_list.push( local_argument_list.push(
[undefined, context, result.data.rows[i].id] [undefined, context, id]
); );
} }
}
return dispatchQueue( return dispatchQueue(
context, context,
repairDocument, repairDocument,
...@@ -12643,14 +12673,18 @@ return new Parser; ...@@ -12643,14 +12673,18 @@ return new Parser;
}); });
}; };
function handleGet(request, resolve, reject) { function handleGet(store, id, resolve, reject) {
var request = store.get(id);
request.onerror = reject; request.onerror = reject;
request.onsuccess = function () { request.onsuccess = function () {
if (request.result) { if (request.result) {
resolve(request.result); resolve(request.result);
} else { } else {
// XXX How to get ID reject(new jIO.util.jIOError(
reject(new jIO.util.jIOError("Cannot find document", 404)); "IndexedDB: cannot find object '" + id + "' in the '" +
store.name + "' store",
404
));
} }
}; };
} }
...@@ -12661,7 +12695,8 @@ return new Parser; ...@@ -12661,7 +12695,8 @@ return new Parser;
return new RSVP.Promise(function (resolve, reject) { return new RSVP.Promise(function (resolve, reject) {
var transaction = openTransaction(db, ["metadata"], "readonly"); var transaction = openTransaction(db, ["metadata"], "readonly");
handleGet( handleGet(
transaction.objectStore("metadata").get(id), transaction.objectStore("metadata"),
id,
resolve, resolve,
reject reject
); );
...@@ -12694,7 +12729,8 @@ return new Parser; ...@@ -12694,7 +12729,8 @@ return new Parser;
); );
} }
handleGet( handleGet(
transaction.objectStore("metadata").get(id), transaction.objectStore("metadata"),
id,
getAttachments, getAttachments,
reject reject
); );
...@@ -12822,7 +12858,8 @@ return new Parser; ...@@ -12822,7 +12858,8 @@ return new Parser;
result_list.push(result); result_list.push(result);
} }
i += 1; i += 1;
handleGet(store.get(buildKeyPath([id, name, i])), handleGet(store,
buildKeyPath([id, name, i]),
(i <= end_index) ? getPart(i) : resolver, (i <= end_index) ? getPart(i) : resolver,
reject reject
); );
...@@ -12831,8 +12868,8 @@ return new Parser; ...@@ -12831,8 +12868,8 @@ return new Parser;
getPart(start_index - 1)(); getPart(start_index - 1)();
} }
// XXX Should raise if key is not good // XXX Should raise if key is not good
handleGet(transaction.objectStore("attachment") handleGet(transaction.objectStore("attachment"),
.get(buildKeyPath([id, name])), buildKeyPath([id, name]),
getBlob, getBlob,
reject reject
); );
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
{ {
"name": "jio", "name": "jio",
"version": "v3.18.0", "version": "v3.19.0",
"license": "LGPLv3", "license": "LGPLv3",
"author": "Nexedi SA", "author": "Nexedi SA",
"contributors": [ "contributors": [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment