Prevent timeout when restoring drive

This commit is contained in:
yflory
2018-07-19 17:51:38 +02:00
parent 2be78deb93
commit d816a2ed9f
4 changed files with 18 additions and 7 deletions

View File

@@ -110,6 +110,8 @@ define([
value: data
}, function (obj) {
cb(obj);
}, {
timeout: 5 * 60 * 1000
});
};
common.addSharedFolder = function (secret, cb) {
@@ -1328,12 +1330,12 @@ define([
});
});
postMessage = function (cmd, data, cb) {
postMessage = function (cmd, data, cb, opts) {
cb = cb || function () {};
chan.query(cmd, data, function (err, data) {
if (err) { return void cb ({error: err}); }
cb(data);
});
}, opts);
};
console.log('Posting CONNECT');

View File

@@ -32,12 +32,14 @@ define([
var chan = {};
// Send a query. channel.query('Q_SOMETHING', { args: "whatever" }, function (reply) { ... });
chan.query = function (q, content, cb) {
chan.query = function (q, content, cb, opts) {
var txid = mkTxid();
opts = opts || {};
var to = opts.timeout || 30000;
var timeout = setTimeout(function () {
delete queries[txid];
//console.log("Timeout making query " + q);
}, 30000);
}, to);
queries[txid] = function (data, msg) {
clearTimeout(timeout);
delete queries[txid];

View File

@@ -21,16 +21,18 @@ define([
var chan = {};
// Send a query. channel.query('Q_SOMETHING', { args: "whatever" }, function (reply) { ... });
chan.query = function (q, content, cb) {
chan.query = function (q, content, cb, opts) {
if (!otherWindow) { throw new Error('not yet initialized'); }
if (!SFrameProtocol[q]) {
throw new Error('please only make queries are defined in sframe-protocol.js');
}
opts = opts || {};
var txid = mkTxid();
var to = opts.timeout || 30000;
var timeout = setTimeout(function () {
delete queries[txid];
console.log("Timeout making query " + q);
}, 30000);
}, to);
queries[txid] = function (data, msg) {
clearTimeout(timeout);
delete queries[txid];