Skip to content

Commit

Permalink
feat: 支持从主仓库 dev 分支同步关卡数据,同步关卡功能提前排除不需要存储的关卡信息
Browse files Browse the repository at this point in the history
  • Loading branch information
dragove committed Aug 19, 2023
1 parent 3d62d53 commit 7ae5845
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/plus/maa/backend/service/ArkLevelService.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class ArkLevelService {
/**
* maa 主仓库,一般不变
*/
@Value("${maa-copilot.github.repo:MaaAssistantArknights/MaaAssistantArknights}")
private String maaRepo;
@Value("${maa-copilot.github.repo:MaaAssistantArknights/MaaAssistantArknights/dev}")
private String maaRepoAndBranch;
/**
* 地图数据所在路径
*/
Expand Down Expand Up @@ -139,6 +139,12 @@ public void runSyncLevelDataTask() {
//根据sha筛选无需更新的地图
List<String> shaList = arkLevelRepo.findAllShaBy().stream().map(ArkLevelSha::getSha).toList();
levelTrees.removeIf(t -> shaList.contains(t.getSha()));
// 排除overview文件、肉鸽、训练关卡和 Guide? 不知道是啥
levelTrees.removeIf(t -> t.getPath().equals("overview.json") ||
t.getPath().contains("roguelike") ||
t.getPath().startsWith("tr_") ||
t.getPath().startsWith("guide_"));
levelTrees.removeIf(t -> t.getPath().contains("roguelike"));
log.info("[LEVEL]{}份地图数据需要更新", levelTrees.size());
if (levelTrees.isEmpty()) {
return;
Expand All @@ -164,7 +170,7 @@ private void download(DownloadTask task, GithubTree tree) {
task.success();
return;
}
String url = String.format("https://raw.githubusercontent.com/%s/master/%s/%s", maaRepo, tilePosPath, fileName);
String url = String.format("https://raw.githubusercontent.com/%s/%s/%s", maaRepoAndBranch, tilePosPath, fileName);
okHttpClient.newCall(new Request.Builder().url(url).build()).enqueue(new Callback() {
@Override
public void onFailure(@NotNull Call call, @NotNull IOException e) {
Expand All @@ -174,7 +180,7 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
try (ResponseBody rspBody = response.body()) {
if (!response.isSuccessful()) {
if (!response.isSuccessful() || rspBody == null) {
task.fail();
log.error("[LEVEL]下载地图数据失败:" + tree.getPath());
return;
Expand Down

0 comments on commit 7ae5845

Please sign in to comment.