Skip to content

Commit 137c7cd

Browse files
author
li-guohao
committed
optimize: 递归导入逻辑由同步到并行
1 parent e491370 commit 137c7cd

2 files changed

Lines changed: 12 additions & 13 deletions

File tree

CHANGELOG.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## 优化
88

99
- 启动时自动加载alist的token
10+
- 递归导入逻辑由同步到并行
1011

1112
# 0.12.6
1213

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import lombok.extern.slf4j.Slf4j;
55
import org.springframework.beans.factory.DisposableBean;
66
import org.springframework.beans.factory.InitializingBean;
7-
import org.springframework.boot.context.event.ApplicationReadyEvent;
87
import org.springframework.context.event.EventListener;
98
import org.springframework.http.HttpEntity;
109
import org.springframework.http.HttpHeaders;
@@ -93,13 +92,12 @@ private Mono<Void> createAttachmentRecursively(List<String> paths, Long parentId
9392
.flatMap(this::saveAListAttachment)
9493
.flatMap(aListAttachment -> {
9594
if (aListAttachment.getIs_dir()) {
96-
List<String> paths1 = aListAttachment.getPaths();
97-
return createAttachmentRecursively(paths1, aListAttachment.getId())
95+
return Mono.defer(() ->
96+
createAttachmentRecursively(aListAttachment.getPaths(), aListAttachment.getId()))
9897
.subscribeOn(Schedulers.boundedElastic());
9998
} else {
10099
return Mono.empty();
101100
}
102-
103101
})
104102
.then();
105103
}
@@ -148,15 +146,15 @@ private Mono<AListAttachment> saveAListAttachment(AListAttachment aListAttachmen
148146
aListAttachment.getParentId(), aListAttachment.getName())
149147
.filter(exists -> !exists)
150148
.flatMap(exists -> attachmentOperate.save(
151-
Attachment.builder()
152-
.parentId(aListAttachment.getParentId())
153-
.name(aListAttachment.getName())
154-
.updateTime(LocalDateTime.now())
155-
.type(type)
156-
.size(aListAttachment.getSize())
157-
.url(aListAttachment.getRaw_url())
158-
.fsPath(getPathByPathArr(aListAttachment.getPaths()))
159-
.build())
149+
Attachment.builder()
150+
.parentId(aListAttachment.getParentId())
151+
.name(aListAttachment.getName())
152+
.updateTime(LocalDateTime.now())
153+
.type(type)
154+
.size(aListAttachment.getSize())
155+
.url(aListAttachment.getRaw_url())
156+
.fsPath(getPathByPathArr(aListAttachment.getPaths()))
157+
.build())
160158
.doOnSuccess(att -> log.debug("Save attachment[{}] for alist[{}]", att.getName(), att.getFsPath())))
161159
.then(attachmentOperate.findByTypeAndParentIdAndName(
162160
type, aListAttachment.getParentId(), aListAttachment.getName()

0 commit comments

Comments
 (0)