Commit 027845e3 authored by Vincent Bechu's avatar Vincent Bechu Committed by Romain Courteaud

ReplicateStorage: signature storage database prop is storage hash

parent 68c2249d
......@@ -55,14 +55,22 @@
stringify(spec.remote_sub_storage) +
stringify(this._query_options)
);
if (spec.signature_sub_storage !== undefined) {
// spec.signature_storage.database = this._signature_hash;
this._signature_sub_storage = jIO.createJIO(spec.signature_sub_storage);
this._custom_signature_sub_storage = true;
} else {
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
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
......@@ -943,10 +951,12 @@
return new RSVP.Queue()
.push(function () {
// Ensure that the document storage is usable
if (context._custom_signature_sub_storage === false) {
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) &&
......
......@@ -237,6 +237,35 @@
);
});
test("signature storage database named as hash", function () {
var jio = jIO.createJIO({
type: "replicate",
signature_storage: {
type: "indexeddb"
},
local_sub_storage: {
type: "uuid",
sub_storage: {
type: "memory"
}
},
remote_sub_storage: {
type: "uuid",
sub_storage: {
type: "memory"
}
}
});
equal(
"jio:_replicate_b9296354cdf1dbe0046de11f57a5a24f8f6a78a8",
jio.__storage._signature_sub_storage.__storage._database_name,
"database equal hash"
);
});
/////////////////////////////////////////////////////////////////
// replicateStorage.get
/////////////////////////////////////////////////////////////////
......
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