Commit 40ef31b0 authored by Vincent Bechu's avatar Vincent Bechu Committed by Romain Courteaud

ReplicateStorage: allow to manually define the signature storage

parent ae47ebe7
......@@ -50,19 +50,25 @@
this._local_sub_storage = jIO.createJIO(spec.local_sub_storage);
this._remote_sub_storage = jIO.createJIO(spec.remote_sub_storage);
this._signature_hash = "_replicate_" + generateHash(
stringify(spec.local_sub_storage) +
stringify(spec.remote_sub_storage) +
stringify(this._query_options)
);
this._signature_sub_storage = jIO.createJIO({
type: "query",
sub_storage: {
type: "document",
document_id: this._signature_hash,
sub_storage: spec.signature_storage || spec.local_sub_storage
}
});
if (spec.hasOwnProperty('signature_sub_storage')) {
this._signature_sub_storage = jIO.createJIO(spec.signature_sub_storage);
this._custom_signature_sub_storage = true;
} else {
this._signature_hash = "_replicate_" + generateHash(
stringify(spec.local_sub_storage) +
stringify(spec.remote_sub_storage) +
stringify(this._query_options)
);
this._signature_sub_storage = jIO.createJIO({
type: "query",
sub_storage: {
type: "document",
document_id: this._signature_hash,
sub_storage: spec.local_sub_storage
}
});
this._custom_signature_sub_storage = false;
}
this._use_remote_post = spec.use_remote_post || false;
// Number of request we allow browser execution for attachments
......@@ -937,16 +943,18 @@
argument_list = arguments,
skip_document_dict = {};
// Do not sync the signature document
skip_document_dict[context._signature_hash] = null;
return new RSVP.Queue()
.push(function () {
// Ensure that the document storage is usable
return context._signature_sub_storage.__storage._sub_storage
.__storage._sub_storage.get(
context._signature_hash
);
if (context._custom_signature_sub_storage === false) {
// Do not sync the signature document
skip_document_dict[context._signature_hash] = null;
return context._signature_sub_storage.__storage._sub_storage
.__storage._sub_storage.get(
context._signature_hash
);
}
})
.push(undefined, function (error) {
if ((error instanceof jIO.util.jIOError) &&
......
......@@ -74,6 +74,7 @@
equal(jio.__storage._check_remote_attachment_deletion, false);
equal(jio.__storage._check_remote_attachment_modification, false);
equal(jio.__storage._custom_signature_sub_storage, false);
equal(jio.__storage._signature_hash,
"_replicate_7209dfbcaff00f6637f939fdd71fa896793ed385");
......@@ -110,9 +111,6 @@
remote_sub_storage: {
type: "replicatestorage500"
},
signature_storage: {
type: "signaturestorage2713"
},
query: {query: 'portal_type: "Foo"', limit: [0, 1234567890]},
use_remote_post: true,
conflict_handling: 3,
......@@ -153,6 +151,7 @@
equal(jio.__storage._check_remote_attachment_deletion, true);
equal(jio.__storage._check_remote_attachment_modification, true);
equal(jio.__storage._custom_signature_sub_storage, false);
ok(jio.__storage._signature_sub_storage instanceof jio.constructor);
equal(jio.__storage._signature_sub_storage.__type, "query");
......@@ -173,7 +172,7 @@
equal(jio.__storage._signature_sub_storage
.__storage._sub_storage
.__storage._sub_storage.__type,
"signaturestorage2713");
"replicatestorage200");
equal(jio.__storage._signature_hash,
"_replicate_11881e431308c0ec8c0e6430be98db380e1b92f8");
......@@ -204,6 +203,36 @@
);
});
test("signature storage database", function () {
var jio = jIO.createJIO({
type: "replicate",
signature_sub_storage: {
type: "memory"
},
local_sub_storage: {
type: "uuid",
sub_storage: {
type: "memory"
}
},
remote_sub_storage: {
type: "uuid",
sub_storage: {
type: "memory"
}
}
});
equal(jio.__storage._custom_signature_sub_storage, true);
ok(jio.__storage._signature_sub_storage instanceof jio.constructor);
equal(jio.__storage._signature_sub_storage.__type, "memory");
ok(!jio.__storage.hasOwnProperty('_signature_hash'),
jio.__storage._signature_hash);
});
/////////////////////////////////////////////////////////////////
// replicateStorage.get
/////////////////////////////////////////////////////////////////
......@@ -701,4 +730,4 @@
});
});
}(jIO, QUnit, Blob));
\ No newline at end of file
}(jIO, QUnit, Blob));
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