Prevent timeout when restoring drive

pull/1/head
yflory 6 years ago
parent 2be78deb93
commit d816a2ed9f

@ -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');

@ -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];

@ -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];

@ -3374,8 +3374,13 @@ define([
/* add a history button */
APP.histConfig = {
onLocal: function () {
UI.addLoadingScreen({ loadingText: "Please be careful" }); // XXX
proxy.drive = history.currentObj.drive;
sframeChan.query("Q_DRIVE_RESTORE", history.currentObj.drive, function () {});
sframeChan.query("Q_DRIVE_RESTORE", history.currentObj.drive, function () {
UI.removeLoadingScreen();
}, {
timeout: 5 * 60 * 1000
});
},
onRemote: function () {},
setHistory: setHistory,

Loading…
Cancel
Save