Ignore:
Timestamp:
04/03/13 13:40:26 (13 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Children:
11439:2a63a9963207, 11445:9594307a3fe2
Message:

Fixed a 'ZeroDivisionError' when downloading a zero lenght file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/utils/serverfiles.py

    r11396 r11438  
    305305 
    306306        readb = 0 
    307         while 1: 
     307        # in case size == 0 skip the loop 
     308        while size > 0: 
    308309            buf = fdown.read(chunksize) 
    309310            readb += len(buf) 
    310311 
    311             while float(readb)/size > lastchunkreport+0.01: 
     312            while float(readb) / size > lastchunkreport+0.01: 
    312313                #print float(readb)/size, lastchunkreport + 0.01, float(readb)/size - lastchunkreport  
    313314                lastchunkreport += 0.01 
     
    670671    def getstring(self): 
    671672        elapsed = max(time.time() - self.starttime, 0.1) 
    672         speed = int(self.state * self.size / 100.0 / elapsed) 
     673        speed = max(int(self.state * self.size / 100.0 / elapsed), 1) 
    673674        eta = (100 - self.state) * self.size / 100.0 / speed 
    674675        return ConsoleProgressBar.getstring(self) + \ 
Note: See TracChangeset for help on using the changeset viewer.