From 18775c5c72b58f9b02b050a650da85b2394d176c Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Tue, 26 Jun 2012 02:18:18 +0200 Subject: [PATCH] Improved the dirlisting's display of sizes --- servefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/servefile b/servefile index e516f94..7049729 100755 --- a/servefile +++ b/servefile @@ -432,12 +432,13 @@ class DirListingHandler(FileBaseHandler): self.wfile.write(listing) def convertSize(self, size): - ext = None - for ext in "BKMGT": + for ext in "KMGT": + size /= 1024.0 if size < 1024.0: break - size /= 1024.0 - return (size, ext) + if ext == "K" and size < 0.1: + size = 0.1 + return (size, ext.strip()) def getCleanPath(self): urlPath = posixpath.normpath(urllib.unquote(self.path)).strip("/")