Skip to content

Commit 9322e73

Browse files
committed
更新aList的url为/d/{path}(?sign={sign})
1 parent 60cbfa7 commit 9322e73

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

CHANGELOG.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# 15.2.0
66

7-
7+
- 更新aList的url为/d/{path}(?sign={sign})
88

99
# v0.12.11
1010

src/main/java/run/ikaros/plugin/alist/AListClient.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import run.ikaros.api.store.enums.AttachmentType;
3030
import run.ikaros.plugin.alist.AListConst.ConfigMapKey;
3131

32+
import java.net.URLEncoder;
33+
import java.nio.charset.StandardCharsets;
3234
import java.time.Duration;
3335
import java.time.LocalDateTime;
3436
import java.util.*;
@@ -90,7 +92,12 @@ private Mono<Void> createAttachmentRecursively(List<String> paths, Long parentId
9092
})
9193
.flatMap(aListAttachment -> {
9294
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);
94101
})
95102
.flatMap(this::saveAListAttachment)
96103
.flatMap(aListAttachment -> {
@@ -309,7 +316,11 @@ public AListToken cm2token(ConfigMap cm) {
309316
if (cmd == null) {
310317
cmd = new HashMap<>();
311318
}
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);
313324
token.setUsername(cmd.get(ConfigMapKey.apiUsername));
314325
token.setPassword(cmd.get(ConfigMapKey.apiPassword));
315326
token.setEnableAutoTokenRefresh(

0 commit comments

Comments
 (0)