@@ -26,7 +26,7 @@ public function has_pending_requests() {
2626 public function enqueue_if_not_exists ( $ url , $ output_path ) {
2727 $ this ->enqueued_resource_id = null ;
2828
29- $ output_path = $ this -> output_root . ' / ' . ltrim ( $ output_path , '/ ' );
29+ $ output_path = ltrim ( $ output_path , '/ ' );
3030 if ( file_exists ( $ output_path ) ) {
3131 // @TODO: Reconsider the return value. The enqueuing operation failed,
3232 // but overall already having a file seems like a success.
@@ -99,13 +99,14 @@ public function poll() {
9999 if ( ! $ this ->client ->await_next_event () ) {
100100 return false ;
101101 }
102- $ event = $ this ->client ->get_event ();
103- $ request = $ this ->client ->get_request ();
104- // The request object we get from the client may be a redirect.
105- // Let's keep referring to the original request.
106- $ original_request_id = $ request ->original_request ()->id ;
107102
108- while ( true ) {
103+ do {
104+ $ event = $ this ->client ->get_event ();
105+ $ request = $ this ->client ->get_request ();
106+ // The request object we get from the client may be a redirect.
107+ // Let's keep referring to the original request.
108+ $ original_request_id = $ this ->client ->get_request ()->original_request ()->id ;
109+
109110 switch ( $ event ) {
110111 case Client::EVENT_GOT_HEADERS :
111112 if ( ! $ request ->is_redirected () ) {
@@ -129,7 +130,7 @@ public function poll() {
129130 fclose ( $ this ->fps [ $ original_request_id ] );
130131 }
131132 if ( isset ( $ this ->output_paths [ $ original_request_id ] ) ) {
132- $ partial_file = $ this ->output_root . ' / ' . $ this -> output_paths [ $ original_request_id ] . '.partial ' ;
133+ $ partial_file = $ this ->output_paths [ $ original_request_id ] . '.partial ' ;
133134 if ( file_exists ( $ partial_file ) ) {
134135 unlink ( $ partial_file );
135136 }
@@ -162,7 +163,7 @@ public function poll() {
162163 }
163164 break ;
164165 }
165- }
166+ } while ( $ this -> client -> await_next_event () );
166167
167168 return true ;
168169 }
0 commit comments