#NEWLINE# @ flow . StateHandler ( next_state = [ 'ReadBuffer' , 'CheckHashes' ] ) #NEWLINE# def ReadBuffer( self , responses ) : #NEWLINE# #INDENT# 'Read the buffer and write to the file.' #NEWLINE# if responses . success : #NEWLINE# #INDENT# response = responses . First ( ) #NEWLINE# if ( not response ) : #NEWLINE# #INDENT# raise IOError ( ( 'Missing hash for offset %s missing' % response . offset ) ) #NEWLINE# #UNINDENT# if ( response . offset <= ( self . state . max_chunk_number * self . CHUNK_SIZE ) ) : #NEWLINE# #INDENT# self . state . fd . AddBlob ( response . data , response . length ) #NEWLINE# self . Log ( 'Received blob hash %s' , response . data . encode ( 'hex' ) ) #NEWLINE# self . Status ( 'Received %s bytes' , self . state . fd . size ) #NEWLINE# self . FetchWindow ( 1 )