|
4 | 4 | import lombok.extern.slf4j.Slf4j; |
5 | 5 | import org.springframework.beans.factory.DisposableBean; |
6 | 6 | import org.springframework.beans.factory.InitializingBean; |
7 | | -import org.springframework.boot.context.event.ApplicationReadyEvent; |
8 | 7 | import org.springframework.context.event.EventListener; |
9 | 8 | import org.springframework.http.HttpEntity; |
10 | 9 | import org.springframework.http.HttpHeaders; |
@@ -93,13 +92,12 @@ private Mono<Void> createAttachmentRecursively(List<String> paths, Long parentId |
93 | 92 | .flatMap(this::saveAListAttachment) |
94 | 93 | .flatMap(aListAttachment -> { |
95 | 94 | 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())) |
98 | 97 | .subscribeOn(Schedulers.boundedElastic()); |
99 | 98 | } else { |
100 | 99 | return Mono.empty(); |
101 | 100 | } |
102 | | - |
103 | 101 | }) |
104 | 102 | .then(); |
105 | 103 | } |
@@ -148,15 +146,15 @@ private Mono<AListAttachment> saveAListAttachment(AListAttachment aListAttachmen |
148 | 146 | aListAttachment.getParentId(), aListAttachment.getName()) |
149 | 147 | .filter(exists -> !exists) |
150 | 148 | .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()) |
160 | 158 | .doOnSuccess(att -> log.debug("Save attachment[{}] for alist[{}]", att.getName(), att.getFsPath()))) |
161 | 159 | .then(attachmentOperate.findByTypeAndParentIdAndName( |
162 | 160 | type, aListAttachment.getParentId(), aListAttachment.getName() |
|
0 commit comments