|
29 | 29 | import run.ikaros.api.store.enums.AttachmentType; |
30 | 30 | import run.ikaros.plugin.alist.AListConst.ConfigMapKey; |
31 | 31 |
|
| 32 | +import java.net.URLEncoder; |
| 33 | +import java.nio.charset.StandardCharsets; |
32 | 34 | import java.time.Duration; |
33 | 35 | import java.time.LocalDateTime; |
34 | 36 | import java.util.*; |
@@ -90,7 +92,12 @@ private Mono<Void> createAttachmentRecursively(List<String> paths, Long parentId |
90 | 92 | }) |
91 | 93 | .flatMap(aListAttachment -> { |
92 | 94 | String path = getPathByPathArr(aListAttachment.getPaths()); |
93 | | - return Mono.just(fetchAttachmentDetail(path, aListAttachment)); |
| 95 | + AListAttachment att = fetchAttachmentDetail(path, aListAttachment); |
| 96 | + String name = path.substring(path.lastIndexOf('/') + 1); |
| 97 | + att.setRaw_url(token.getUrl() |
| 98 | + + "/d" + path.replace(name, URLEncoder.encode(name, StandardCharsets.UTF_8).replace("+", "%20")) |
| 99 | + + (StringUtils.isNotBlank(att.getSign()) ? "?sign=" + att.getSign() : "")); |
| 100 | + return Mono.just(att); |
94 | 101 | }) |
95 | 102 | .flatMap(this::saveAListAttachment) |
96 | 103 | .flatMap(aListAttachment -> { |
@@ -309,7 +316,11 @@ public AListToken cm2token(ConfigMap cm) { |
309 | 316 | if (cmd == null) { |
310 | 317 | cmd = new HashMap<>(); |
311 | 318 | } |
312 | | - token.setUrl(cmd.get(ConfigMapKey.apiBaseUrl)); |
| 319 | + String url = cmd.get(ConfigMapKey.apiBaseUrl); |
| 320 | + if (url.endsWith("/")) { |
| 321 | + url = url.substring(0, url.length() - 1); |
| 322 | + } |
| 323 | + token.setUrl(url); |
313 | 324 | token.setUsername(cmd.get(ConfigMapKey.apiUsername)); |
314 | 325 | token.setPassword(cmd.get(ConfigMapKey.apiPassword)); |
315 | 326 | token.setEnableAutoTokenRefresh( |
|
0 commit comments