diff MoinMoin/util/send_file.py @ 1156:4cd6611b0cf8

Fix send_file(None) and send_file unittest
author Sam Toyer <samATqxcvDOTnet>
date Wed, 14 Dec 2011 10:29:18 +1000
parents e61194bb558e
children 4ac437141bbe
line wrap: on
line diff
--- a/MoinMoin/util/send_file.py	Wed Dec 14 00:45:49 2011 +0100
+++ b/MoinMoin/util/send_file.py	Wed Dec 14 10:29:18 2011 +1000
@@ -119,11 +119,13 @@
     # See `_ensure_sequence` in werkzeug/wrappers.py
     if filename:
         fsize = os.path.getsize(filename)
-    else:
+    elif file:
         # Seek 0 bytes (0) from the end of the file (2)
         file.seek(0, 2)
         fsize = file.tell()
         file.seek(0, 0)
+    else:
+        fsize = 0
     headers.add('Content-Length', fsize)
 
     if as_attachment: