From d74862012930933089d94b6754d80c5554b8945b Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 23 Oct 2018 14:22:18 +0200 Subject: [PATCH] Add timeout when downloading a file in drive export --- www/settings/inner.js | 2 +- www/settings/make-backup.js | 43 ++++++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/www/settings/inner.js b/www/settings/inner.js index 618d76364..5c167a41a 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -1009,7 +1009,7 @@ define([ if (err) { return void cb(err); } if (obj.error) { return void cb(obj.error); } cb(null, obj.data); - }, { timeout: 5 * 60 * 1000 }); + }, { timeout: 60000 }); }; var ui = createExportUI(); diff --git a/www/settings/make-backup.js b/www/settings/make-backup.js index c49e8b986..4a1b68aee 100644 --- a/www/settings/make-backup.js +++ b/www/settings/make-backup.js @@ -65,6 +65,32 @@ define([ ctx.sem.take(function (give) { var g = give(); if (ctx.stop) { return; } + + var to; + + var done = function () { + if (ctx.stop) { return; } + if (to) { clearTimeout(to); } + //setTimeout(g, 2000); + g(); + w(); + ctx.done++; + ctx.updateProgress('download', {max: ctx.max, current: ctx.done}); + }; + + var error = function (err) { + if (ctx.stop) { return; } + done(); + return void ctx.errors.push({ + error: err, + data: fData + }); + }; + + to = setTimeout(function () { + error('TIMEOUT'); + }, 60000); + setTimeout(function () { if (ctx.stop) { return; } var opts = { @@ -73,23 +99,6 @@ define([ var rawName = fData.filename || fData.title || 'File'; console.log(rawName); - var done = function () { - if (ctx.stop) { return; } - //setTimeout(g, 2000); - g(); - w(); - ctx.done++; - ctx.updateProgress('download', {max: ctx.max, current: ctx.done}); - }; - var error = function (err) { - if (ctx.stop) { return; } - done(); - return void ctx.errors.push({ - error: err, - data: fData - }); - }; - // Pads (pad,code,slide,kanban,poll,...) var todoPad = function () { ctx.get({