aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-12-28 10:12:25 +0000
committerMario <mario@mariovavti.com>2020-12-28 10:12:25 +0000
commit9670833a5ddc3c24343202fda6f29875e9b3b10b (patch)
treed7ce12d622000bcddabb86c398b4a76a9bc52272 /view/js
parentf4bfa779425dc4f55db86bc554624bb05b09c49f (diff)
downloadvolse-hubzilla-9670833a5ddc3c24343202fda6f29875e9b3b10b.tar.gz
volse-hubzilla-9670833a5ddc3c24343202fda6f29875e9b3b10b.tar.bz2
volse-hubzilla-9670833a5ddc3c24343202fda6f29875e9b3b10b.zip
files_ng: provide a fallback in case the server timed out on compressing the zip file
Diffstat (limited to 'view/js')
-rw-r--r--view/js/main.js10
-rw-r--r--view/js/mod_cloud.js35
2 files changed, 43 insertions, 2 deletions
diff --git a/view/js/main.js b/view/js/main.js
index 7df705603..3e3fd057c 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -1997,3 +1997,13 @@ function sse_fallback() {
sse_handleNotifications(obj, false, false);
});
}
+
+function makeid(length) {
+ var result = '';
+ var characters = 'abcdef0123456789';
+ var charactersLength = characters.length;
+ for ( var i = 0; i < length; i++ ) {
+ result += characters.charAt(Math.floor(Math.random() * charactersLength));
+ }
+ return result;
+}
diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js
index aa9d308eb..aeaac8c69 100644
--- a/view/js/mod_cloud.js
+++ b/view/js/mod_cloud.js
@@ -70,8 +70,11 @@ $(document).ready(function () {
$('body').css('cursor', 'wait');
$.jGrowl('Please stand by while your download is being prepared...', { sticky: false, theme: 'info', life: 10000 });
+ var download_token = makeid(32);
+
let data = [
{name: 'attach_path', value: window.location.pathname},
+ {name: 'download_token', value: download_token},
{name: 'channel_id', value: channelId},
{name: 'attach_ids[]', value: id}
]
@@ -79,10 +82,22 @@ $(document).ready(function () {
$.post('attach', data, function (data) {
if (data.success) {
$('body').css('cursor', 'auto');
- window.location.href = '/attach/download?token=' + data.token;
+ window.location.href = '/attach/download?token=' + data.token + '&download_token=' + download_token;
+ clearInterval(fallback);
}
});
+ // fallback if server timed out
+
+ var fallback = setInterval(function(){ $.get('/attach/check?download_token=' + download_token, function(data){
+ if (data.success) {
+ $('body').css('cursor', 'auto');
+ window.location.href = '/attach/download?token=' + data.token;
+ clearInterval(fallback);
+ }
+
+ }); }, 30000);
+
});
$('.cloud-tool-delete-btn').on('click', function (e) {
@@ -298,18 +313,34 @@ $(document).ready(function () {
$('body').css('cursor', 'wait');
$.jGrowl('Please stand by while your download is being prepared...', { sticky: false, theme: 'info', life: 10000 });
+ var download_token = makeid(32);
+
post_data.push(
{name: 'attach_path', value: window.location.pathname},
+ {name: 'download_token', value: download_token},
{name: 'channel_id', value: channelId},
);
$.post('attach', post_data, function (data) {
if (data.success) {
$('body').css('cursor', 'auto');
- window.location.href = '/attach/download?token=' + data.token;
+ window.location.href = '/attach/download?token=' + data.token + '&download_token=' + download_token;
+ clearInterval(fallback);
}
});
+ // fallback if server timed out
+
+ var fallback = setInterval(function(){ $.get('/attach/check?download_token=' + download_token, function(data){
+ if (data.success) {
+ $('body').css('cursor', 'auto');
+ window.location.href = '/attach/download?token=' + data.token;
+ clearInterval(fallback);
+ }
+
+ }); }, 30000);
+
+
});
$('#cloud-multi-tool-delete-btn').on('click', function (e) {