@@ -84,15 +84,14 @@ def put(uptoken, key, f, fsize, extra):
84
84
if extra .chunk_size is None :
85
85
extra .chunk_size = _chunk_size
86
86
87
- client = auth .up .Client (uptoken )
88
87
for i in xrange (0 , block_cnt ):
89
88
try_time = extra .try_times
90
89
read_length = _block_size
91
90
if (i + 1 )* _block_size > fsize :
92
91
read_length = fsize - i * _block_size
93
92
data_slice = f .read (read_length )
94
93
while True :
95
- err = resumable_block_put (client , data_slice , i , extra )
94
+ err = resumable_block_put (data_slice , i , extra , uptoken )
96
95
if err is None :
97
96
break
98
97
@@ -101,34 +100,38 @@ def put(uptoken, key, f, fsize, extra):
101
100
return None , err_put_failed
102
101
print err , ".. retry"
103
102
104
- return mkfile (client , key , fsize , extra )
103
+ mkfile_client = auth .up .Client (uptoken , extra .progresses [- 1 ]["host" ])
104
+ return mkfile (mkfile_client , key , fsize , extra )
105
105
106
106
# ----------------------------------------------------------
107
107
108
- def resumable_block_put (client , block , index , extra ):
108
+ def resumable_block_put (block , index , extra , uptoken ):
109
109
block_size = len (block )
110
110
111
+ mkblk_client = auth .up .Client (uptoken , conf .UP_HOST )
111
112
if extra .progresses [index ] is None or "ctx" not in extra .progresses [index ]:
112
113
end_pos = extra .chunk_size - 1
113
114
if block_size < extra .chunk_size :
114
115
end_pos = block_size - 1
115
116
chunk = block [: end_pos ]
116
117
crc32 = gen_crc32 (chunk )
117
118
chunk = bytearray (chunk )
118
- extra .progresses [index ], err = mkblock (client , block_size , chunk )
119
+ extra .progresses [index ], err = mkblock (mkblk_client , block_size , chunk )
119
120
if not extra .progresses [index ]["crc32" ] == crc32 :
120
121
return err_unmatched_checksum
121
122
if err is not None :
122
123
extra .notify_err (index , end_pos + 1 , err )
123
124
return err
124
125
extra .notify (index , end_pos + 1 , extra .progresses [index ])
125
126
127
+ bput_client = auth .up .Client (uptoken , extra .progresses [index ]["host" ])
126
128
while extra .progresses [index ]["offset" ] < block_size :
127
129
offset = extra .progresses [index ]["offset" ]
128
130
chunk = block [offset : offset + extra .chunk_size - 1 ]
129
131
crc32 = gen_crc32 (chunk )
130
132
chunk = bytearray (chunk )
131
- extra .progresses [index ], err = putblock (client , extra .progresses [index ], chunk )
133
+
134
+ extra .progresses [index ], err = putblock (bput_client , extra .progresses [index ], chunk )
132
135
if not extra .progresses [index ]["crc32" ] == crc32 :
133
136
return err_unmatched_checksum
134
137
if err is not None :
0 commit comments