Commit f864e6e4 authored by Romain Courteaud's avatar Romain Courteaud

ReplicateStorage: use a property as attachment hash

Speed up attachment replication by using a document property to check if there was a change.
The attachment content is NEVER checked, as this configuration expect the document to be modified when an attachment is created, modified or deleted.
In case of conflict, follow the document conflict resolution result.
parent 8abcfa83
...@@ -558,7 +558,184 @@ ...@@ -558,7 +558,184 @@
}); });
} }
function repairDocumentAttachment(context, id) { function propagateFastAttachmentDeletion(queue, id, name, storage) {
return queue
.push(function () {
return storage.removeAttachment(id, name);
});
}
function propagateFastAttachmentModification(queue, id, key, source,
destination, signature, hash) {
return queue
.push(function () {
return signature.getAttachment(id, key, {format: 'json'})
.push(undefined, function (error) {
if ((error instanceof jIO.util.jIOError) &&
(error.status_code === 404)) {
return {hash: null};
}
throw error;
})
.push(function (result) {
if (result.hash !== hash) {
return source.getAttachment(id, key)
.push(function (blob) {
return destination.putAttachment(id, key, blob);
})
.push(function () {
return signature.putAttachment(id, key, JSON.stringify({
hash: hash
}));
});
}
});
});
}
function repairFastDocumentAttachment(context, id,
signature_hash,
signature_attachment_hash,
signature_from_local) {
if (signature_hash === signature_attachment_hash) {
// No replication to do
return;
}
return new RSVP.Queue()
.push(function () {
return RSVP.all([
context._signature_sub_storage.allAttachments(id),
context._local_sub_storage.allAttachments(id),
context._remote_sub_storage.allAttachments(id)
]);
})
.push(function (result_list) {
var key,
source_attachment_dict,
destination_attachment_dict,
source,
destination,
push_argument_list = [],
delete_argument_list = [],
signature_attachment_dict = result_list[0],
local_attachment_dict = result_list[1],
remote_attachment_list = result_list[2],
check_local_modification =
context._check_local_attachment_modification,
check_local_creation = context._check_local_attachment_creation,
check_local_deletion = context._check_local_attachment_deletion,
check_remote_modification =
context._check_remote_attachment_modification,
check_remote_creation = context._check_remote_attachment_creation,
check_remote_deletion = context._check_remote_attachment_deletion;
if (signature_from_local) {
source_attachment_dict = local_attachment_dict;
destination_attachment_dict = remote_attachment_list;
source = context._local_sub_storage;
destination = context._remote_sub_storage;
} else {
source_attachment_dict = remote_attachment_list;
destination_attachment_dict = local_attachment_dict;
source = context._remote_sub_storage;
destination = context._local_sub_storage;
check_local_modification = check_remote_modification;
check_local_creation = check_remote_creation;
check_local_deletion = check_remote_deletion;
check_remote_creation = check_local_creation;
check_remote_deletion = check_local_deletion;
}
// Push all source attachments
for (key in source_attachment_dict) {
if (source_attachment_dict.hasOwnProperty(key)) {
if ((check_local_creation &&
!signature_attachment_dict.hasOwnProperty(key)) ||
(check_local_modification &&
signature_attachment_dict.hasOwnProperty(key))) {
push_argument_list.push([
undefined,
id,
key,
source,
destination,
context._signature_sub_storage,
signature_hash
]);
}
}
}
// Delete remaining signature + remote attachments
for (key in signature_attachment_dict) {
if (signature_attachment_dict.hasOwnProperty(key)) {
if (check_local_deletion &&
!source_attachment_dict.hasOwnProperty(key)) {
delete_argument_list.push([
undefined,
id,
key,
context._signature_sub_storage
]);
}
}
}
for (key in destination_attachment_dict) {
if (destination_attachment_dict.hasOwnProperty(key)) {
if (!source_attachment_dict.hasOwnProperty(key)) {
if ((check_local_deletion &&
signature_attachment_dict.hasOwnProperty(key)) ||
(check_remote_creation &&
!signature_attachment_dict.hasOwnProperty(key))) {
delete_argument_list.push([
undefined,
id,
key,
destination
]);
}
}
}
}
return RSVP.all([
dispatchQueue(
context,
propagateFastAttachmentModification,
push_argument_list,
context._parallel_operation_attachment_amount
),
dispatchQueue(
context,
propagateFastAttachmentDeletion,
delete_argument_list,
context._parallel_operation_attachment_amount
)
]);
})
.push(function () {
// Mark that all attachments have been synchronized
return context._signature_sub_storage.put(id, {
hash: signature_hash,
attachment_hash: signature_hash,
from_local: signature_from_local
});
});
}
function repairDocumentAttachment(context, id, signature_hash_key,
signature_hash,
signature_attachment_hash,
signature_from_local) {
if (signature_hash_key !== undefined) {
return repairFastDocumentAttachment(context, id,
signature_hash,
signature_attachment_hash,
signature_from_local);
}
var skip_attachment_dict = {}; var skip_attachment_dict = {};
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -644,10 +821,13 @@ ...@@ -644,10 +821,13 @@
options) { options) {
var result = new RSVP.Queue(), var result = new RSVP.Queue(),
post_id, post_id,
to_skip = true; to_skip = true,
from_local;
if (options === undefined) { if (options === undefined) {
options = {}; options = {};
} }
from_local = options.from_local;
if (doc === null) { if (doc === null) {
result result
.push(function () { .push(function () {
...@@ -709,7 +889,8 @@ ...@@ -709,7 +889,8 @@
.push(function () { .push(function () {
to_skip = true; 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
}); });
}) })
.push(function () { .push(function () {
...@@ -730,7 +911,8 @@ ...@@ -730,7 +911,8 @@
}) })
.push(function () { .push(function () {
return context._signature_sub_storage.put(id, { return context._signature_sub_storage.put(id, {
"hash": hash hash: hash,
from_local: from_local
}); });
}); });
} }
...@@ -754,7 +936,14 @@ ...@@ -754,7 +936,14 @@
// ie, replication should prevent losing user data // ie, replication should prevent losing user data
// Synchronize attachments before, to ensure // Synchronize attachments before, to ensure
// all of them will be deleted too // all of them will be deleted too
return repairDocumentAttachment(context, id) var result;
if (context._signature_hash_key !== undefined) {
result = destination.remove(id)
.push(function () {
return context._signature_sub_storage.remove(id);
});
} else {
result = repairDocumentAttachment(context, id)
.push(function () { .push(function () {
return destination.allAttachments(id); return destination.allAttachments(id);
}) })
...@@ -771,7 +960,9 @@ ...@@ -771,7 +960,9 @@
return; return;
} }
throw error; throw error;
}) });
}
return result
.push(function () { .push(function () {
skip_document_dict[id] = null; skip_document_dict[id] = null;
// No need to sync attachment twice on this document // No need to sync attachment twice on this document
...@@ -787,6 +978,7 @@ ...@@ -787,6 +978,7 @@
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore, conflict_ignore,
options) { options) {
var from_local = options.from_local;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
if (options.signature_hash_key !== undefined) { if (options.signature_hash_key !== undefined) {
...@@ -825,7 +1017,8 @@ ...@@ -825,7 +1017,8 @@
} }
return context._signature_sub_storage.put(id, { return context._signature_sub_storage.put(id, {
"hash": local_hash hash: local_hash,
from_local: from_local
}) })
.push(function () { .push(function () {
skip_document_dict[id] = null; skip_document_dict[id] = null;
...@@ -845,6 +1038,7 @@ ...@@ -845,6 +1038,7 @@
skip_deleted_document_dict, skip_deleted_document_dict,
{use_post: ((options.use_post) && {use_post: ((options.use_post) &&
(remote_hash === null)), (remote_hash === null)),
from_local: from_local,
create_new_document: create_new_document:
((remote_hash === null) && ((remote_hash === null) &&
(status_hash !== null)) (status_hash !== null))
...@@ -874,6 +1068,7 @@ ...@@ -874,6 +1068,7 @@
skip_deleted_document_dict, skip_deleted_document_dict,
{use_post: ((options.use_revert_post) && {use_post: ((options.use_revert_post) &&
(local_hash === null)), (local_hash === null)),
from_local: !from_local,
create_new_document: ((local_hash === null) && create_new_document: ((local_hash === null) &&
(status_hash !== null))} (status_hash !== null))}
); );
...@@ -886,6 +1081,7 @@ ...@@ -886,6 +1081,7 @@
local_hash, id, skip_document_dict, local_hash, id, skip_document_dict,
skip_deleted_document_dict, skip_deleted_document_dict,
{use_post: options.use_post, {use_post: options.use_post,
from_local: from_local,
create_new_document: create_new_document:
(status_hash !== null)}); (status_hash !== null)});
} }
...@@ -1089,9 +1285,14 @@ ...@@ -1089,9 +1285,14 @@
}); });
} }
function repairDocument(queue, context, id) { function repairDocument(queue, context, id, signature_hash_key,
signature_hash, signature_attachment_hash,
signature_from_local) {
queue.push(function () { queue.push(function () {
return repairDocumentAttachment(context, id); return repairDocumentAttachment(context, id, signature_hash_key,
signature_hash,
signature_attachment_hash,
signature_from_local);
}); });
} }
...@@ -1180,7 +1381,8 @@ ...@@ -1180,7 +1381,8 @@
check_creation: context._check_local_creation, check_creation: context._check_local_creation,
check_deletion: context._check_local_deletion, check_deletion: context._check_local_deletion,
operation_amount: context._parallel_operation_amount, operation_amount: context._parallel_operation_amount,
signature_hash_key: context._signature_hash_key signature_hash_key: context._signature_hash_key,
from_local: true
}) })
.push(function () { .push(function () {
return signature_allDocs; return signature_allDocs;
...@@ -1209,7 +1411,8 @@ ...@@ -1209,7 +1411,8 @@
check_creation: context._check_remote_creation, check_creation: context._check_remote_creation,
check_deletion: context._check_remote_deletion, check_deletion: context._check_remote_deletion,
operation_amount: context._parallel_operation_amount, operation_amount: context._parallel_operation_amount,
signature_hash_key: context._signature_hash_key signature_hash_key: context._signature_hash_key,
from_local: false
}); });
} }
}) })
...@@ -1222,20 +1425,24 @@ ...@@ -1222,20 +1425,24 @@
context._check_remote_attachment_deletion) { context._check_remote_attachment_deletion) {
// Attachments are synchronized if and only if their parent document // Attachments are synchronized if and only if their parent document
// has been also marked as synchronized. // has been also marked as synchronized.
return context._signature_sub_storage.allDocs() return context._signature_sub_storage.allDocs({
select_list: ['hash', 'attachment_hash', 'from_local']
})
.push(function (result) { .push(function (result) {
var i, var i,
local_argument_list = [], local_argument_list = [],
id, row,
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; row = result.data.rows[i];
// Do not synchronize attachment if one version of the document // Do not synchronize attachment if one version of the document
// is deleted but not pushed to the other storage // is deleted but not pushed to the other storage
if (!skip_deleted_document_dict.hasOwnProperty(id)) { if (!skip_deleted_document_dict.hasOwnProperty(row.id)) {
local_argument_list.push( local_argument_list.push(
[undefined, context, id] [undefined, context, row.id, context._signature_hash_key,
row.value.hash, row.value.attachment_hash,
row.value.from_local]
); );
} }
} }
......
...@@ -141,6 +141,7 @@ ...@@ -141,6 +141,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -260,6 +261,7 @@ ...@@ -260,6 +261,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -386,6 +388,7 @@ ...@@ -386,6 +388,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -424,6 +427,7 @@ ...@@ -424,6 +427,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "bar dynetag" hash: "bar dynetag"
}); });
}) })
...@@ -493,6 +497,7 @@ ...@@ -493,6 +497,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -567,6 +572,7 @@ ...@@ -567,6 +572,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -642,6 +648,7 @@ ...@@ -642,6 +648,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -719,6 +726,7 @@ ...@@ -719,6 +726,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -795,6 +803,7 @@ ...@@ -795,6 +803,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -870,6 +879,7 @@ ...@@ -870,6 +879,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "bar dynetag" hash: "bar dynetag"
}); });
}) })
...@@ -945,6 +955,7 @@ ...@@ -945,6 +955,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "bar dynetag" hash: "bar dynetag"
}); });
}) })
...@@ -1021,6 +1032,7 @@ ...@@ -1021,6 +1032,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "bar dynetag" hash: "bar dynetag"
}); });
}) })
...@@ -1099,6 +1111,7 @@ ...@@ -1099,6 +1111,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "bar dynetag" hash: "bar dynetag"
}); });
}) })
...@@ -1296,6 +1309,7 @@ ...@@ -1296,6 +1309,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -1336,6 +1350,7 @@ ...@@ -1336,6 +1350,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -1379,6 +1394,7 @@ ...@@ -1379,6 +1394,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo2 dynetag" hash: "foo2 dynetag"
}); });
}) })
...@@ -1454,6 +1470,7 @@ ...@@ -1454,6 +1470,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo2 dynetag" hash: "foo2 dynetag"
}); });
}) })
...@@ -1536,6 +1553,7 @@ ...@@ -1536,6 +1553,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -1582,6 +1600,7 @@ ...@@ -1582,6 +1600,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "foo3 dynetag" hash: "foo3 dynetag"
}); });
}) })
...@@ -1667,6 +1686,7 @@ ...@@ -1667,6 +1686,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -1719,6 +1739,7 @@ ...@@ -1719,6 +1739,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -1789,6 +1810,7 @@ ...@@ -1789,6 +1810,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo4 dynetag" hash: "foo4 dynetag"
}); });
}) })
...@@ -1880,6 +1902,7 @@ ...@@ -1880,6 +1902,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "foo5 dynetag" hash: "foo5 dynetag"
}); });
}) })
...@@ -1971,6 +1994,7 @@ ...@@ -1971,6 +1994,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -2032,6 +2056,7 @@ ...@@ -2032,6 +2056,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo99 dynetag" hash: "foo99 dynetag"
}); });
}) })
...@@ -2161,6 +2186,7 @@ ...@@ -2161,6 +2186,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -2171,7 +2197,7 @@ ...@@ -2171,7 +2197,7 @@
test("local document deletion with attachment", function () { test("local document deletion with attachment", function () {
stop(); stop();
expect(7); expect(10);
var id, var id,
context = this, context = this,
...@@ -2206,26 +2232,26 @@ ...@@ -2206,26 +2232,26 @@
.then(function () { .then(function () {
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .fail(function (error) {
deepEqual(result, { ok(error instanceof jIO.util.jIOError);
title: "foo", equal(error.message, "Cannot find document: " + id);
foo_etag: "foo etag" equal(error.status_code, 404);
});
})
.then(function () {
return context.jio.__storage._remote_sub_storage
.getAttachment(id, 'foo', {format: 'text'});
})
.then(function (result) {
equal(result, big_string);
}) })
.then(function () { .then(function () {
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .fail(function (error) {
deepEqual(result, { ok(error instanceof jIO.util.jIOError);
hash: "foo dynetag" equal(
}); error.message.indexOf(
"Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " +
"jio_document/"
),
0,
error.message
);
equal(error.status_code, 404);
}) })
.always(function () { .always(function () {
start(); start();
...@@ -2350,6 +2376,7 @@ ...@@ -2350,6 +2376,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -2360,7 +2387,7 @@ ...@@ -2360,7 +2387,7 @@
test("remote document deletion with attachment", function () { test("remote document deletion with attachment", function () {
stop(); stop();
expect(7); expect(10);
var id, var id,
context = this, context = this,
...@@ -2394,25 +2421,26 @@ ...@@ -2394,25 +2421,26 @@
.then(function () { .then(function () {
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .fail(function (error) {
deepEqual(result, { ok(error instanceof jIO.util.jIOError);
title: "foo", equal(error.message, "Cannot find document: " + id);
foo_etag: "foo etag" equal(error.status_code, 404);
});
})
.then(function () {
return context.jio.getAttachment(id, 'foo', {format: 'text'});
})
.then(function (result) {
equal(result, big_string);
}) })
.then(function () { .then(function () {
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .fail(function (error) {
deepEqual(result, { ok(error instanceof jIO.util.jIOError);
hash: "foo dynetag" equal(
}); error.message.indexOf(
"Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " +
"jio_document/"
),
0,
error.message
);
equal(error.status_code, 404);
}) })
.always(function () { .always(function () {
start(); start();
...@@ -2522,6 +2550,7 @@ ...@@ -2522,6 +2550,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "foo99 dynetag" hash: "foo99 dynetag"
}); });
}) })
...@@ -2710,6 +2739,7 @@ ...@@ -2710,6 +2739,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "foo99 dynetag" hash: "foo99 dynetag"
}); });
}) })
...@@ -2800,6 +2830,7 @@ ...@@ -2800,6 +2830,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
...@@ -2846,6 +2877,7 @@ ...@@ -2846,6 +2877,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo99 dynetag" hash: "foo99 dynetag"
}); });
}) })
...@@ -2972,6 +3004,7 @@ ...@@ -2972,6 +3004,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo99 dynetag" hash: "foo99 dynetag"
}); });
}) })
...@@ -3099,6 +3132,7 @@ ...@@ -3099,6 +3132,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo99 dynetag" hash: "foo99 dynetag"
}); });
}) })
...@@ -3185,6 +3219,7 @@ ...@@ -3185,6 +3219,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo99 dynetag" hash: "foo99 dynetag"
}); });
}) })
...@@ -3312,6 +3347,7 @@ ...@@ -3312,6 +3347,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo99 dynetag" hash: "foo99 dynetag"
}); });
}) })
...@@ -3582,6 +3618,7 @@ ...@@ -3582,6 +3618,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "foo dynetag" hash: "foo dynetag"
}); });
}) })
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -232,6 +233,7 @@ ...@@ -232,6 +233,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -343,6 +345,7 @@ ...@@ -343,6 +345,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -379,6 +382,7 @@ ...@@ -379,6 +382,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "6799f3ea80e325b89f19589282a343c376c1f1af" hash: "6799f3ea80e325b89f19589282a343c376c1f1af"
}); });
}) })
...@@ -522,6 +526,7 @@ ...@@ -522,6 +526,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -587,6 +592,7 @@ ...@@ -587,6 +592,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -653,6 +659,7 @@ ...@@ -653,6 +659,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -718,6 +725,7 @@ ...@@ -718,6 +725,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "a0a1b37cee3709101b752c56e59b9d66cce09961" hash: "a0a1b37cee3709101b752c56e59b9d66cce09961"
}); });
}) })
...@@ -783,6 +791,7 @@ ...@@ -783,6 +791,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "6799f3ea80e325b89f19589282a343c376c1f1af" hash: "6799f3ea80e325b89f19589282a343c376c1f1af"
}); });
}) })
...@@ -848,6 +857,7 @@ ...@@ -848,6 +857,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "6799f3ea80e325b89f19589282a343c376c1f1af" hash: "6799f3ea80e325b89f19589282a343c376c1f1af"
}); });
}) })
...@@ -914,6 +924,7 @@ ...@@ -914,6 +924,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "45efa2292d54cc4ce1f726ea197bc0b9721fc1dc" hash: "45efa2292d54cc4ce1f726ea197bc0b9721fc1dc"
}); });
}) })
...@@ -981,6 +992,7 @@ ...@@ -981,6 +992,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "6799f3ea80e325b89f19589282a343c376c1f1af" hash: "6799f3ea80e325b89f19589282a343c376c1f1af"
}); });
}) })
...@@ -1155,6 +1167,7 @@ ...@@ -1155,6 +1167,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -1194,6 +1207,7 @@ ...@@ -1194,6 +1207,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -1236,6 +1250,7 @@ ...@@ -1236,6 +1250,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab" hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"
}); });
}) })
...@@ -1296,6 +1311,7 @@ ...@@ -1296,6 +1311,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab" hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"
}); });
}) })
...@@ -1363,6 +1379,7 @@ ...@@ -1363,6 +1379,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -1408,6 +1425,7 @@ ...@@ -1408,6 +1425,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "4b1dde0f80ac38514771a9d25b5278e38f560e0f" hash: "4b1dde0f80ac38514771a9d25b5278e38f560e0f"
}); });
}) })
...@@ -1478,6 +1496,7 @@ ...@@ -1478,6 +1496,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -1524,6 +1543,7 @@ ...@@ -1524,6 +1543,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -1575,6 +1595,7 @@ ...@@ -1575,6 +1595,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "6f700e813022233a785692585484c21cb5a412fd" hash: "6f700e813022233a785692585484c21cb5a412fd"
}); });
}) })
...@@ -1645,6 +1666,7 @@ ...@@ -1645,6 +1666,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "7bea6f87fd1dda14e340e5b14836cc8578fd615f" hash: "7bea6f87fd1dda14e340e5b14836cc8578fd615f"
}); });
}) })
...@@ -1715,6 +1737,7 @@ ...@@ -1715,6 +1737,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -1768,6 +1791,7 @@ ...@@ -1768,6 +1791,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f" hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f"
}); });
}) })
...@@ -1883,6 +1907,7 @@ ...@@ -1883,6 +1907,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -1945,6 +1970,7 @@ ...@@ -1945,6 +1970,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -2057,6 +2083,7 @@ ...@@ -2057,6 +2083,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -2117,6 +2144,7 @@ ...@@ -2117,6 +2144,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -2221,6 +2249,7 @@ ...@@ -2221,6 +2249,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f" hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f"
}); });
}) })
...@@ -2368,6 +2397,7 @@ ...@@ -2368,6 +2397,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: false,
hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f" hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f"
}); });
}) })
...@@ -2438,6 +2468,7 @@ ...@@ -2438,6 +2468,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
...@@ -2483,6 +2514,7 @@ ...@@ -2483,6 +2514,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f" hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f"
}); });
}) })
...@@ -2592,6 +2624,7 @@ ...@@ -2592,6 +2624,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f" hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f"
}); });
}) })
...@@ -2703,6 +2736,7 @@ ...@@ -2703,6 +2736,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f" hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f"
}); });
}) })
...@@ -2774,6 +2808,7 @@ ...@@ -2774,6 +2808,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f" hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f"
}); });
}) })
...@@ -2884,6 +2919,7 @@ ...@@ -2884,6 +2919,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f" hash: "8ed3a474128b6e0c0c7d3dd51b1a06ebfbf6722f"
}); });
}) })
...@@ -3112,6 +3148,7 @@ ...@@ -3112,6 +3148,7 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5" hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
}); });
}) })
......
...@@ -3742,7 +3742,10 @@ ...@@ -3742,7 +3742,10 @@
.get(id); .get(id);
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, {hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"}); deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
});
// remote document untouched // remote document untouched
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
...@@ -3910,7 +3913,10 @@ ...@@ -3910,7 +3913,10 @@
.get(id); .get(id);
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, {hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"}); deepEqual(result, {
from_local: true,
hash: "5ea9013447539ad65de308cbd75b5826a2ae30e5"
});
// local document untouched // local document untouched
return context.jio.get(id); return context.jio.get(id);
...@@ -4080,7 +4086,10 @@ ...@@ -4080,7 +4086,10 @@
.get(id); .get(id);
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, {hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"}); deepEqual(result, {
from_local: false,
hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"
});
// remote document untouched // remote document untouched
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
...@@ -4246,7 +4255,10 @@ ...@@ -4246,7 +4255,10 @@
.get(id); .get(id);
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, {hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"}); deepEqual(result, {
from_local: true,
hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"
});
// local document untouched // local document untouched
return context.jio.get(id); return context.jio.get(id);
...@@ -4417,7 +4429,10 @@ ...@@ -4417,7 +4429,10 @@
.get(id); .get(id);
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, {hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"}); deepEqual(result, {
from_local: false,
hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"
});
// remote document untouched // remote document untouched
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
...@@ -4584,7 +4599,10 @@ ...@@ -4584,7 +4599,10 @@
.get(id); .get(id);
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, {hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"}); deepEqual(result, {
from_local: true,
hash: "9819187e39531fdc9bcfd40dbc6a7d3c78fe8dab"
});
// local document untouched // local document untouched
return context.jio.get(id); return context.jio.get(id);
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<script src="jio.storage/replicatestorage_repair.tests.js"></script> <script src="jio.storage/replicatestorage_repair.tests.js"></script>
<script src="jio.storage/replicatestorage_repairattachment.tests.js"></script> <script src="jio.storage/replicatestorage_repairattachment.tests.js"></script>
<script src="jio.storage/replicatestorage_fastrepair.tests.js"></script> <script src="jio.storage/replicatestorage_fastrepair.tests.js"></script>
<script src="jio.storage/replicatestorage_fastrepairattachment.tests.js"></script>
<script src="jio.storage/shastorage.tests.js"></script> <script src="jio.storage/shastorage.tests.js"></script>
<!--script src="jio.storage/qiniustorage.tests.js"></script--> <!--script src="jio.storage/qiniustorage.tests.js"></script-->
......
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