@@ -153,6 +153,17 @@ static esp_gmf_err_t _http_open(esp_gmf_io_handle_t self)
153153 return ESP_GMF_ERR_FAIL ;
154154 }
155155
156+ if (http -> data_bus == NULL ) {
157+ err = esp_gmf_db_new_block (1 , http_io_cfg -> out_buf_size , & http -> data_bus );
158+ if (err != ESP_GMF_ERR_OK ) {
159+ ESP_LOGE (TAG , "Failed to create the buffer for %d, sz: %d, %s-%p" , http_io_cfg -> dir , http_io_cfg -> out_buf_size , OBJ_GET_TAG (http ), http );
160+ return err ;
161+ }
162+ esp_gmf_data_bus_type_t db_type = 0 ;
163+ esp_gmf_db_get_type (http -> data_bus , & db_type );
164+ http -> base .type = db_type ;
165+ }
166+
156167 if (http_io_cfg -> dir == ESP_GMF_IO_DIR_WRITER ) {
157168 err = esp_http_client_open (http -> client , -1 );
158169 if (err == ESP_GMF_ERR_OK ) {
@@ -213,17 +224,6 @@ static esp_gmf_err_t _http_open(esp_gmf_io_handle_t self)
213224 }
214225 esp_gmf_io_set_size (self , info .size );
215226
216- if (http -> data_bus == NULL ) {
217- err = esp_gmf_db_new_block (1 , http_io_cfg -> out_buf_size , & http -> data_bus );
218- if (err != ESP_GMF_ERR_OK ) {
219- ESP_LOGE (TAG , "Failed to create the download buffer, sz: %d, %s-%p" , http_io_cfg -> out_buf_size , OBJ_GET_TAG (http ), http );
220- return err ;
221- }
222- esp_gmf_data_bus_type_t db_type = 0 ;
223- esp_gmf_db_get_type (http -> data_bus , & db_type );
224- http -> base .type = db_type ;
225- }
226-
227227 return ESP_GMF_ERR_OK ;
228228}
229229
0 commit comments