-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize: subject episode attachment matching operate. (#581)
* feat: 当条目同步窗口只有一个第三方的时候,自动选择该第三方 #580 * feat: 在条目新增时,检测到剧集没有条目,自动创建个默认的剧集条目 #579 * feat: 当条目没有剧集的时候,批量绑定按钮加个禁用和提示 #578 * docs: update CHANGELOG.MD * feat: 条目被移除时,条目的封面附件未被移除 * fix: 小说条目绑定资源提示非视频媒体 #576 feat: 剧集批量附件绑定,支持文件名更多格式:` 01 ` `[01]` `EP01` `-01-` `_01_` * docs: update CHANGELOG.MD * build: change version to 0.12.2
- Loading branch information
GuoHao
authored
Jun 16, 2024
1 parent
8d417af
commit 5b67bee
Showing
15 changed files
with
208 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.13.0 | ||
version=0.12.2 |
55 changes: 55 additions & 0 deletions
55
...java/run/ikaros/server/core/attachment/listener/AttachmentSubjectCoverChangeListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package run.ikaros.server.core.attachment.listener; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Objects; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.context.event.EventListener; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
import run.ikaros.api.infra.utils.FileUtils; | ||
import run.ikaros.server.core.subject.event.SubjectRemoveEvent; | ||
import run.ikaros.server.store.entity.SubjectEntity; | ||
import run.ikaros.server.store.repository.AttachmentRepository; | ||
|
||
@Slf4j | ||
@Component | ||
public class AttachmentSubjectCoverChangeListener { | ||
private final AttachmentRepository attachmentRepository; | ||
|
||
public AttachmentSubjectCoverChangeListener( | ||
AttachmentRepository attachmentRepository) { | ||
this.attachmentRepository = attachmentRepository; | ||
} | ||
|
||
/** | ||
* Construct. | ||
*/ | ||
@EventListener(SubjectRemoveEvent.class) | ||
public Mono<Void> onSubjectRemove(SubjectRemoveEvent event) { | ||
SubjectEntity subjectEntity = event.getEntity(); | ||
Long subjectId = subjectEntity.getId(); | ||
String cover = subjectEntity.getCover(); | ||
if (Objects.isNull(subjectId) || subjectId < 0 || StringUtils.isBlank(cover)) { | ||
return Mono.empty(); | ||
} | ||
return attachmentRepository.findByUrl(cover) | ||
.map(attachmentEntity -> { | ||
String fsPath = attachmentEntity.getFsPath(); | ||
if (StringUtils.isBlank(fsPath) || fsPath.startsWith("http")) { | ||
return attachmentEntity; | ||
} | ||
try { | ||
FileUtils.deletePathAndContentIfExists(Path.of(fsPath)); | ||
log.debug("Delete subject cover url success in fs path for fsPath[{}].", | ||
fsPath); | ||
} catch (IOException e) { | ||
log.error("Delete subject cover url failed in fs path for fsPath[{}].", | ||
fsPath, e); | ||
} | ||
return attachmentEntity; | ||
}) | ||
.flatMap(attachmentRepository::delete); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
spring: | ||
r2dbc: | ||
url: r2dbc:h2:file:///~/ikaros-dev/database/ikaros?MODE=MySQL&DB_CLOSE_ON_EXIT=FALSE |