Skip to content

Commit

Permalink
prettier format
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Zheng committed Jan 18, 2024
1 parent 43a05fb commit 14a114a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
28 changes: 19 additions & 9 deletions src/crawler.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,11 @@ private function _touch_lane()
public function Release_lane()
{
$lane_file = $this->json_local_path() . '.pid';
if (!file_exists($lane_file)) return;
if (!file_exists($lane_file)) {
return;
}

self::debug("Release lane");
self::debug('Release lane');
unlink($lane_file);
}

Expand All @@ -633,7 +635,7 @@ private function _check_valid_lane($strict_mode = false)
if ($pid && LITESPEED_LANE_HASH != $pid) {
// If lane file is older than 1h, ignore
if (time() - filemtime($lane_file) > 3600) {
self::debug("Lane file is older than 1h, releasing lane");
self::debug('Lane file is older than 1h, releasing lane');
$this->Release_lane();
return true;
}
Expand Down Expand Up @@ -661,7 +663,7 @@ private function _do_running()
if (!$this->_check_valid_lane(true)) {
$this->_end_reason = 'lane_invalid';
self::debug('🛑 The crawler lane is used by newer crawler.');
throw new \Exception("invalid crawler lane");
throw new \Exception('invalid crawler lane');
}
// Update time
$this->_touch_lane();
Expand Down Expand Up @@ -850,10 +852,18 @@ private function _multi_request($rows, $options)
*/
private function _status2title($status)
{
if ($status == 'H') return '✅ Hit';
if ($status == 'M') return '😊 Miss';
if ($status == 'B') return '😅 Blacklisted';
if ($status == 'N') return '😅 Blacklisted';
if ($status == 'H') {
return '✅ Hit';
}
if ($status == 'M') {
return '😊 Miss';
}
if ($status == 'B') {
return '😅 Blacklisted';
}
if ($status == 'N') {
return '😅 Blacklisted';
}
return '🛸 Unknown';
}

Expand Down Expand Up @@ -1315,7 +1325,7 @@ public function handler()
}
break;

// Handle the ajax request to proceed crawler manually by admin
// Handle the ajax request to proceed crawler manually by admin
case self::TYPE_START:
self::start_async();
break;
Expand Down
18 changes: 9 additions & 9 deletions src/img-optm.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -966,10 +966,10 @@ public function pull($manual = false)

try {
while ($img_rows = $wpdb->get_results($_q)) {
self::debug("timeout left: " . ($endts - time()) . 's');
self::debug('timeout left: ' . ($endts - time()) . 's');
if (function_exists('set_time_limit')) {
$endts += 600;
self::debug("Endtime extended to " . date("Ymd H:i:s", $endts));
self::debug('Endtime extended to ' . date('Ymd H:i:s', $endts));
set_time_limit(600); // This will be no more important as we use noabort now
}
// Disabled as we use noabort
Expand Down Expand Up @@ -1054,7 +1054,7 @@ public function pull($manual = false)
$image_url .
']'
);
throw new \Exception("Failed to pull image " . (!empty($response->status_code) ? $response->status_code : '') . " [url] " . $image_url);
throw new \Exception('Failed to pull image ' . (!empty($response->status_code) ? $response->status_code : '') . ' [url] ' . $image_url);
return;
}
}
Expand Down Expand Up @@ -1191,10 +1191,10 @@ public function pull($manual = false)
$complete_action($request_response, $cnt);
}
}
self::debug("Current batch pull finished");
self::debug('Current batch pull finished');
}
} catch (\Exception $e) {
Admin_Display::error("Image pull process failure: " . $e->getMessage());
Admin_Display::error('Image pull process failure: ' . $e->getMessage());
}

// Notify IAPI images taken
Expand Down Expand Up @@ -2093,10 +2093,10 @@ public function handler()
self::start_async();
break;

/**
* Batch switch
* @since 1.6.3
*/
/**
* Batch switch
* @since 1.6.3
*/
case self::TYPE_BATCH_SWITCH_ORI:
case self::TYPE_BATCH_SWITCH_OPTM:
$this->_batch_switch($type);
Expand Down
2 changes: 1 addition & 1 deletion src/task.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static function async_call($type)
Router::TYPE => $type,
);
$url = add_query_arg($qs, admin_url('admin-ajax.php'));
self::debug("async call to " . $url);
self::debug('async call to ' . $url);
wp_remote_post(esc_url_raw($url), $args);
}

Expand Down

0 comments on commit 14a114a

Please sign in to comment.