diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/Page.java b/src/main/java/com/github/zxbu/webdavteambition/model/Page.java index 091741d..1f67313 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/Page.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/Page.java @@ -1,17 +1,17 @@ package com.github.zxbu.webdavteambition.model; public class Page { - private int offset; + private String marker; private int limit; private String order_by; private String order_direction; - public int getOffset() { - return offset; + public String getMarker() { + return marker; } - public void setOffset(int offset) { - this.offset = offset; + public void setMarker(String marker) { + this.marker = marker; } public int getLimit() { diff --git a/src/main/java/com/github/zxbu/webdavteambition/model/result/TFileListResult.java b/src/main/java/com/github/zxbu/webdavteambition/model/result/TFileListResult.java index e855577..0973279 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/model/result/TFileListResult.java +++ b/src/main/java/com/github/zxbu/webdavteambition/model/result/TFileListResult.java @@ -4,6 +4,7 @@ import java.util.List; public class TFileListResult { private List items; + private String next_marker; public List getItems() { return items; @@ -12,4 +13,12 @@ public class TFileListResult { public void setItems(List items) { this.items = items; } + + public String getNext_marker() { + return next_marker; + } + + public void setNext_marker(String next_marker) { + this.next_marker = next_marker; + } } diff --git a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java index 944e22c..ce28b9e 100644 --- a/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java +++ b/src/main/java/com/github/zxbu/webdavteambition/store/AliYunDriverClientService.java @@ -59,17 +59,7 @@ public class AliYunDriverClientService { } private Set getTFiles2(String nodeId) { - FileListRequest listQuery = new FileListRequest(); - listQuery.setOffset(0); - listQuery.setLimit(10000); - listQuery.setOrder_by("updated_at"); - listQuery.setOrder_direction("DESC"); - listQuery.setDrive_id(client.getDriveId()); - listQuery.setParent_file_id(nodeId); - String json = client.post("/file/list", listQuery); - TFileListResult tFileListResult = JsonUtil.readValue(json, new TypeReference>() { - }); - List tFileList = tFileListResult.getItems(); + List tFileList = fileListFromApi(nodeId, null, new ArrayList<>()); tFileList.sort(Comparator.comparing(TFile::getUpdated_at).reversed()); Set tFileSets = new LinkedHashSet<>(); for (TFile tFile : tFileList) { @@ -81,6 +71,24 @@ public class AliYunDriverClientService { return tFileSets; } + private List fileListFromApi(String nodeId, String marker, List all) { + FileListRequest listQuery = new FileListRequest(); + listQuery.setMarker(marker); + listQuery.setLimit(100); + listQuery.setOrder_by("updated_at"); + listQuery.setOrder_direction("DESC"); + listQuery.setDrive_id(client.getDriveId()); + listQuery.setParent_file_id(nodeId); + String json = client.post("/file/list", listQuery); + TFileListResult tFileListResult = JsonUtil.readValue(json, new TypeReference>() { + }); + all.addAll(tFileListResult.getItems()); + if (!StringUtils.hasLength(tFileListResult.getNext_marker())) { + return all; + } + return fileListFromApi(nodeId, tFileListResult.getNext_marker(), all); + } + private Map toMap(Object o) { try {