vendor/tramline

changeset 11:0075e64fe07e gracinet-progress-bar

Don't wait for the first 100KB to initiate the progress store
author gracinet
date Sun, 22 Feb 2009 20:28:34 +0000
parents 8255ba231de3
children c77f592b081f
files src/tramline/core.py
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line diff
     1.1 --- a/src/tramline/core.py
     1.2 +++ b/src/tramline/core.py
     1.3 @@ -380,10 +380,13 @@
     1.4          blocks = self.uploaded / REPORT_BLOCKSIZE
     1.5          if blocks > self._uploaded_blocks:
     1.6              self._uploaded_blocks = blocks
     1.7 -            if self.progress_id is not None:
     1.8 -                f = open(get_progress_path(req, self.progress_id), 'w')
     1.9 -                f.write(str(self.uploaded))
    1.10 -                f.close()
    1.11 +            self._storeProgress(req)
    1.12 +
    1.13 +    def _storeProgress(self, req):
    1.14 +        if self.progress_id is not None:
    1.15 +            f = open(get_progress_path(req, self.progress_id), 'w')
    1.16 +            f.write(str(self.uploaded))
    1.17 +            f.close()
    1.18  
    1.19      def pushInputLine(self, data, out):
    1.20          # collect data
    1.21 @@ -506,6 +509,8 @@
    1.22              # for stat requests, and not sure the user agent can know and store
    1.23              # the full socket info of the upload for requesting.
    1.24              self.progress_id = out.req.connection.remote_ip + '-' + line.strip()
    1.25 +            # initialisation of the store
    1.26 +            self._storeProgress(out.req)
    1.27  
    1.28      def handle_data(self, line, out):
    1.29          out.write(line)