fixed small files not working

This commit is contained in:
Daniel Gultsch 2015-07-24 17:46:32 +02:00
parent 7f6be7e97a
commit 96b39250b2

View File

@ -104,7 +104,7 @@ class HttpHandler(BaseHTTPRequestHandler):
os.makedirs(os.path.dirname(filename)) os.makedirs(os.path.dirname(filename))
remaining = length remaining = length
f = open(filename,'wb') f = open(filename,'wb')
data = self.rfile.read(4096) data = self.rfile.read(min(4096,remaining))
while data and remaining >= 0: while data and remaining >= 0:
remaining -= len(data) remaining -= len(data)
f.write(data) f.write(data)
@ -169,8 +169,8 @@ if __name__ == "__main__":
global config global config
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-c", "--config", type=unicode, default='config.yml', help='Specify alternate config file.') parser.add_argument("-c", "--config", default='config.yml', help='Specify alternate config file.')
parser.add_argument("-l", "--logfile", type=unicode, default=None, help='File where the server log will be stored. If not specified log to stdout.') parser.add_argument("-l", "--logfile", default=None, help='File where the server log will be stored. If not specified log to stdout.')
args = parser.parse_args() args = parser.parse_args()
with open(args.config,'r') as ymlfile: with open(args.config,'r') as ymlfile: