diff options
Diffstat (limited to 'apps/files/js/filelist.js')
-rw-r--r-- | apps/files/js/filelist.js | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 60fcd865880..86c6e225115 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -431,13 +431,32 @@ var sourceImage = icon.attr('src'); icon.attr('src', sourceImage.replace('actions/download.svg', 'loading-small.gif')); - // TODO proper detection of "download has started" - setTimeout(function(){ - icon.attr('src', sourceImage); - downloadFileaction.removeClass('disabled'); - }, 2000); + var randomString = Math.random().toString(36).substring(2); + + var isCookieSet = function(name, value) { + var cookies = document.cookie.split(';'); + for (var i=0; i < cookies.length; i++) { + var cookie = cookies[i].split('='); + if (cookie[0].trim() === name && cookie[1].trim() === value) { + return true; + } + } + return false; + }; + + var checkForDownloadCookie = function() { + console.log('check'); + if (!isCookieSet('ocDownloadStarted', randomString)){ + setTimeout(checkForDownloadCookie, 500); + } else { + console.log('boom'); + icon.attr('src', sourceImage); + downloadFileaction.removeClass('disabled'); + } + }; - OC.redirect(this.getDownloadUrl(files, dir)); + OC.redirect(this.getDownloadUrl(files, dir) + '&downloadStartSecret=' + randomString); + checkForDownloadCookie(); return false; }, |