Skip to content

Commit 4e020be

Browse files
committed
fix: 统一变量
1 parent 0270f2a commit 4e020be

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

laravel/app/Http/Repository/BusRepository.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ private function getPostBusList($line, $refresh = false)
123123
is_dir($path) || mkdir($path, 0777, true);
124124

125125
// 2.0 判断是否已经有此条线路搜索
126-
if ($refresh || !file_exists($path.'/serialize_'.$line.'.txt')) {
126+
$fileName = $path.'/serialize_'.$line.'.txt';
127+
if ($refresh || !file_exists($fileName)) {
127128
// 1. 获取 Token
128129
$data = $this->getToken();
129130

@@ -163,7 +164,6 @@ private function getPostBusList($line, $refresh = false)
163164
$arrayData = $queryList->rules($rules)->query()->getData();
164165
$str = serialize($arrayData->all());
165166
//缓存 此条线路替换a标签的数据
166-
$fileName = $path.'/serialize_'.$line.'.txt';
167167
file_put_contents($fileName, $str);
168168
//抛出异常if (!$rs)
169169
// 车次较多时候数据库操作太频繁,先放入 队列 中批量处理。。。
@@ -184,8 +184,11 @@ private function getPostBusList($line, $refresh = false)
184184
// }
185185
} else {
186186
// 2.1 文件存在直接读取
187-
$serialize = file_get_contents($path.'/serialize_'.$line.'.txt');//线路列表
187+
$serialize = file_get_contents($fileName);//线路列表
188188
$arrayData = unserialize($serialize);
189+
if (empty($arrayData)) {
190+
unlink($fileName);
191+
}
189192
}
190193

191194
return $arrayData;

0 commit comments

Comments
 (0)