mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-17 04:44:40 +08:00
fix(conversation): tolerate non-path-safe ids when cleaning attachments (issue #36)
This commit is contained in:
parent
8ad0fca4ef
commit
0ecfec474e
@ -21,6 +21,7 @@ import vip.mate.workspace.conversation.vo.MessageVO;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.InvalidPathException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -791,7 +792,17 @@ public class ConversationService {
|
|||||||
* 清理会话关联的附件文件
|
* 清理会话关联的附件文件
|
||||||
*/
|
*/
|
||||||
public void cleanAttachmentFiles(String conversationId) {
|
public void cleanAttachmentFiles(String conversationId) {
|
||||||
Path dir = UPLOAD_ROOT.resolve(conversationId);
|
Path dir;
|
||||||
|
try {
|
||||||
|
dir = UPLOAD_ROOT.resolve(conversationId);
|
||||||
|
} catch (InvalidPathException e) {
|
||||||
|
// Conversation id contains characters illegal on this filesystem
|
||||||
|
// (e.g. ':' in cron:<jobId> on Windows). No attachments could
|
||||||
|
// ever have been written under such an id on this OS, so there
|
||||||
|
// is nothing to clean.
|
||||||
|
log.debug("Skipping attachment cleanup for non-path-safe conversation id: {}", conversationId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!Files.exists(dir)) {
|
if (!Files.exists(dir)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user