From a8a4191f1a7a19e67367aa77bd9238519cfc6fbc Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 11 Apr 2015 12:13:41 +0200 Subject: [PATCH] dont re-download cached parts for multipart items --- static/js/cacheDialog.js | 1 + static/js/fs.js | 55 ++++++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/static/js/cacheDialog.js b/static/js/cacheDialog.js index 1b7b770c..60ab3d06 100644 --- a/static/js/cacheDialog.js +++ b/static/js/cacheDialog.js @@ -13,6 +13,7 @@ pandora.ui.cacheDialog = function() { }, { id: 'item', + operator: '+', title: Ox._('Item'), visible: true, width: 48 diff --git a/static/js/fs.js b/static/js/fs.js index 2a0a85bf..8f399010 100644 --- a/static/js/fs.js +++ b/static/js/fs.js @@ -33,34 +33,41 @@ pandora.fs = (function() { downloadPart(0); function downloadPart(part) { - that.downloadVideoURL(id, pandora.user.ui.videoResolution, part + 1, false, function(result) { - result.progress = 1/parts * (part + result.progress); - that.downloads[id].progress = result.progress; - if (result.cancel) { - that.downloads[id].cancel = result.cancel; - } - if (result.total) { - sizes[part] = result.total; - that.downloads[id].size = Ox.sum(sizes); - } - if (result.url) { - if (part + 1 == parts) { - delete that.downloads[id]; - active = false; - if (queue.length) { - var next = queue.shift(); - setTimeout(function() { - cacheVideo(next[0], next[1]); - }); - } - } else { + if (that.getVideoURL(id, pandora.user.ui.videoResolution, part + 1)) { + done(); + else { + that.downloadVideoURL(id, pandora.user.ui.videoResolution, part + 1, false, function(result) { + result.progress = 1/parts * (part + result.progress); + that.downloads[id].progress = result.progress; + if (result.cancel) { + that.downloads[id].cancel = result.cancel; + } + if (result.total) { + sizes[part] = result.total; + that.downloads[id].size = Ox.sum(sizes); + } + if (result.url) { + done(); + } + callback && callback(result); + }); + } + function done() { + if (part + 1 == parts) { + delete that.downloads[id]; + active = false; + if (queue.length) { + var next = queue.shift(); setTimeout(function() { - downloadPart(part + 1); + cacheVideo(next[0], next[1]); }); } + } else { + setTimeout(function() { + downloadPart(part + 1); + }); } - callback && callback(result); - }); + } } }); }