Skip to content

Commit

Permalink
更新aList的url为/d/{path}(?sign={sign})
Browse files Browse the repository at this point in the history
  • Loading branch information
chivehao committed Sep 16, 2024
1 parent 60cbfa7 commit 9322e73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# 15.2.0


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

# v0.12.11

Expand Down
15 changes: 13 additions & 2 deletions src/main/java/run/ikaros/plugin/alist/AListClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import run.ikaros.api.store.enums.AttachmentType;
import run.ikaros.plugin.alist.AListConst.ConfigMapKey;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
Expand Down Expand Up @@ -90,7 +92,12 @@ private Mono<Void> createAttachmentRecursively(List<String> paths, Long parentId
})
.flatMap(aListAttachment -> {
String path = getPathByPathArr(aListAttachment.getPaths());
return Mono.just(fetchAttachmentDetail(path, aListAttachment));
AListAttachment att = fetchAttachmentDetail(path, aListAttachment);
String name = path.substring(path.lastIndexOf('/') + 1);
att.setRaw_url(token.getUrl()
+ "/d" + path.replace(name, URLEncoder.encode(name, StandardCharsets.UTF_8).replace("+", "%20"))
+ (StringUtils.isNotBlank(att.getSign()) ? "?sign=" + att.getSign() : ""));
return Mono.just(att);
})
.flatMap(this::saveAListAttachment)
.flatMap(aListAttachment -> {
Expand Down Expand Up @@ -309,7 +316,11 @@ public AListToken cm2token(ConfigMap cm) {
if (cmd == null) {
cmd = new HashMap<>();
}
token.setUrl(cmd.get(ConfigMapKey.apiBaseUrl));
String url = cmd.get(ConfigMapKey.apiBaseUrl);
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}
token.setUrl(url);
token.setUsername(cmd.get(ConfigMapKey.apiUsername));
token.setPassword(cmd.get(ConfigMapKey.apiPassword));
token.setEnableAutoTokenRefresh(
Expand Down

0 comments on commit 9322e73

Please sign in to comment.