master
elf 4 months ago
parent a173ccdae1
commit e6c9945e3e

@ -1082,6 +1082,36 @@ class AutoPackController extends Think
public function clearPkg() {
$client = new ToolOssClient();
$client->listObjects();
$marker = '';
do {
$list = $client->listObjects('GamePack/', $marker, 100);
$urls = [];
foreach ($list->getObjectList() as $obj) {
$urls[] = '"https://qy-plat.oss-cn-hangzhou.aliyuncs.com/' . $obj->getKey() . '"';
}
if (empty($urls)) {
break;
}
$urlsStr = implode(",", $urls);
$rows = M("apply", 'tab_')->field('pack_url, game_id')->where("group_id in ({$urlsStr})")->find();
$packUrls = [];
$needDelUrls = [];
foreach ($rows as $row) {
$packUrls[] = $row['pack_url'];
if (!in_array($row['game_id'], [282, 283, 277, 273])) {
$needDelUrls[] = $row['pack_url'];
}
}
$needDelUrls = array_unique(array_merge($needDelUrls, array_diff($urls, $packUrls)));
var_dump($needDelUrls);
if (empty($list->getNextMarker())) {
break;
} else {
$marker = $list->getNextMarker();
}
} while (true);
}
}

@ -119,9 +119,12 @@ class OssClient implements StorageClient {
/**
* 删除文件
*/
public function listObjects()
public function listObjects($prefix, $marker = '', $maxKeys = 500)
{
$listObject = $this->client->listObjects($this->bucket, ['prefix' => 'GamePack/', 'max-keys' => 1000, 'marker' => 'GamePack/278_71a13facf90535fe.ipa']);
var_dump($listObject);
$options = ['prefix' => $prefix, 'max-keys' => $maxKeys];
if ($marker) {
$options['marker'] = $marker;
}
return $this->client->listObjects($this->bucket, ['prefix' => $prefix, 'max-keys' => $maxKeys, 'marker' => $marker]);
}
}
Loading…
Cancel
Save