@@ -26,7 +26,7 @@ public function has_pending_requests() {
26
26
public function enqueue_if_not_exists ( $ url , $ output_path ) {
27
27
$ this ->enqueued_resource_id = null ;
28
28
29
- $ output_path = $ this -> output_root . ' / ' . ltrim ( $ output_path , '/ ' );
29
+ $ output_path = ltrim ( $ output_path , '/ ' );
30
30
if ( file_exists ( $ output_path ) ) {
31
31
// @TODO: Reconsider the return value. The enqueuing operation failed,
32
32
// but overall already having a file seems like a success.
@@ -99,13 +99,14 @@ public function poll() {
99
99
if ( ! $ this ->client ->await_next_event () ) {
100
100
return false ;
101
101
}
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 ;
107
102
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
+
109
110
switch ( $ event ) {
110
111
case Client::EVENT_GOT_HEADERS :
111
112
if ( ! $ request ->is_redirected () ) {
@@ -129,7 +130,7 @@ public function poll() {
129
130
fclose ( $ this ->fps [ $ original_request_id ] );
130
131
}
131
132
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 ' ;
133
134
if ( file_exists ( $ partial_file ) ) {
134
135
unlink ( $ partial_file );
135
136
}
@@ -162,7 +163,7 @@ public function poll() {
162
163
}
163
164
break ;
164
165
}
165
- }
166
+ } while ( $ this -> client -> await_next_event () );
166
167
167
168
return true ;
168
169
}
0 commit comments