multihttp: Don't attempt to return progress if download hasn't started yet

Sat, 02 Jan 2010 06:06:48 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Sat, 02 Jan 2010 06:06:48 +0000
changeset 5
053850e0624b
parent 4
a20981a6d88b
child 6
5c415faedb1f

multihttp: Don't attempt to return progress if download hasn't started yet

libs/multihttp.lua file | annotate | diff | comparison | revisions
--- a/libs/multihttp.lua	Sat Jan 02 06:06:19 2010 +0000
+++ b/libs/multihttp.lua	Sat Jan 02 06:06:48 2010 +0000
@@ -64,13 +64,15 @@
 function progress(batch)
 	local progress = {};
 	for url, request in pairs(batch.urls) do
-		local p = {};
-		p.bytes_downloaded = request.havebodylength;
-		p.bytes_total = request.bodylength;
-		if p.bytes_total then
-			p.percent = 100/(p.bytes_total/p.bytes_downloaded);
+		if request ~= true then
+			local p = {};
+			p.bytes_downloaded = request.havebodylength;
+			p.bytes_total = request.bodylength;
+			if p.bytes_total then
+				p.percent = 100/(p.bytes_total/p.bytes_downloaded);
+			end
+			progress[url] = p;
 		end
-		progress[url] = p;
 	end
 	return progress;
 end

mercurial