diff --git a/src/main/java/im/zhaojun/zfile/module/storage/service/base/AbstractMicrosoftDriveService.java b/src/main/java/im/zhaojun/zfile/module/storage/service/base/AbstractMicrosoftDriveService.java
index 247014d..27775b6 100644
--- a/src/main/java/im/zhaojun/zfile/module/storage/service/base/AbstractMicrosoftDriveService.java
+++ b/src/main/java/im/zhaojun/zfile/module/storage/service/base/AbstractMicrosoftDriveService.java
@@ -2,22 +2,23 @@ package im.zhaojun.zfile.module.storage.service.base;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
-import cn.hutool.http.HttpRequest;
+import cn.hutool.http.ContentType;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import im.zhaojun.zfile.module.storage.constant.StorageConfigConstant;
-import im.zhaojun.zfile.module.storage.model.dto.OAuth2TokenDTO;
-import im.zhaojun.zfile.module.storage.model.entity.StorageSourceConfig;
-import im.zhaojun.zfile.module.storage.model.param.MicrosoftDriveParam;
-import im.zhaojun.zfile.module.storage.service.StorageSourceConfigService;
-import im.zhaojun.zfile.module.storage.model.bo.RefreshTokenCacheBO;
import im.zhaojun.zfile.core.constant.ZFileConstant;
import im.zhaojun.zfile.core.exception.StorageSourceRefreshTokenException;
+import im.zhaojun.zfile.core.exception.ZFileRetryException;
import im.zhaojun.zfile.core.util.StringUtils;
+import im.zhaojun.zfile.module.storage.constant.StorageConfigConstant;
+import im.zhaojun.zfile.module.storage.model.bo.RefreshTokenCacheBO;
+import im.zhaojun.zfile.module.storage.model.dto.OAuth2TokenDTO;
+import im.zhaojun.zfile.module.storage.model.entity.StorageSourceConfig;
import im.zhaojun.zfile.module.storage.model.enums.FileTypeEnum;
+import im.zhaojun.zfile.module.storage.model.param.MicrosoftDriveParam;
import im.zhaojun.zfile.module.storage.model.result.FileItemResult;
+import im.zhaojun.zfile.module.storage.service.StorageSourceConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpEntity;
@@ -25,6 +26,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.retry.RetryCallback;
+import org.springframework.retry.support.RetryTemplate;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
@@ -80,7 +83,18 @@ public abstract class AbstractMicrosoftDriveService fileList(String folderPath) {
folderPath = StringUtils.trimStartSlashes(folderPath);
- String fullPath = StringUtils.concat(param.getBasePath(), folderPath);
+ String fullPath = StringUtils.concatTrimEndSlashes(param.getBasePath(), folderPath);
List result = new ArrayList<>();
- String nextLink = null;
+ String nextPageLink = null;
do {
String requestUrl;
- if (nextLink != null) {
- nextLink = nextLink.replace("+", "%2B");
- requestUrl = URLUtil.decode(nextLink);
- }else if (ZFileConstant.PATH_SEPARATOR.equalsIgnoreCase(fullPath) || "".equalsIgnoreCase(fullPath)) {
+ // 如果有下一页链接,则优先取下一页
+ // 如果没有则判断是根目录还是子目录
+ if (nextPageLink != null) {
+ nextPageLink = nextPageLink.replace("+", "%2B");
+ requestUrl = URLUtil.decode(nextPageLink);
+ } else if (ZFileConstant.PATH_SEPARATOR.equalsIgnoreCase(fullPath) || "".equalsIgnoreCase(fullPath)) {
requestUrl = DRIVER_ROOT_URL;
} else {
requestUrl = DRIVER_ITEMS_URL;
}
- fullPath = StringUtils.trimEndSlashes(fullPath);
-
- JSONObject root;
-
- HttpHeaders headers = new HttpHeaders();
- headers.set("storageId", storageId.toString());
- HttpEntity