dont re-download cached parts for multipart items

This commit is contained in:
j 2015-04-11 12:13:41 +02:00
parent c743ad7a71
commit a8a4191f1a
2 changed files with 32 additions and 24 deletions

View file

@ -13,6 +13,7 @@ pandora.ui.cacheDialog = function() {
}, },
{ {
id: 'item', id: 'item',
operator: '+',
title: Ox._('Item'), title: Ox._('Item'),
visible: true, visible: true,
width: 48 width: 48

View file

@ -33,34 +33,41 @@ pandora.fs = (function() {
downloadPart(0); downloadPart(0);
function downloadPart(part) { function downloadPart(part) {
that.downloadVideoURL(id, pandora.user.ui.videoResolution, part + 1, false, function(result) { if (that.getVideoURL(id, pandora.user.ui.videoResolution, part + 1)) {
result.progress = 1/parts * (part + result.progress); done();
that.downloads[id].progress = result.progress; else {
if (result.cancel) { that.downloadVideoURL(id, pandora.user.ui.videoResolution, part + 1, false, function(result) {
that.downloads[id].cancel = result.cancel; result.progress = 1/parts * (part + result.progress);
} that.downloads[id].progress = result.progress;
if (result.total) { if (result.cancel) {
sizes[part] = result.total; that.downloads[id].cancel = result.cancel;
that.downloads[id].size = Ox.sum(sizes); }
} if (result.total) {
if (result.url) { sizes[part] = result.total;
if (part + 1 == parts) { that.downloads[id].size = Ox.sum(sizes);
delete that.downloads[id]; }
active = false; if (result.url) {
if (queue.length) { done();
var next = queue.shift(); }
setTimeout(function() { callback && callback(result);
cacheVideo(next[0], next[1]); });
}); }
} function done() {
} else { if (part + 1 == parts) {
delete that.downloads[id];
active = false;
if (queue.length) {
var next = queue.shift();
setTimeout(function() { setTimeout(function() {
downloadPart(part + 1); cacheVideo(next[0], next[1]);
}); });
} }
} else {
setTimeout(function() {
downloadPart(part + 1);
});
} }
callback && callback(result); }
});
} }
}); });
} }