Skip to content

Commit d1f797f

Browse files
committed
Check if attachmentDir already exists
1 parent 09e6437 commit d1f797f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/main/java/mimeparser/MimeMessageConverter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,12 @@ public String replace(Matcher m) throws Exception {
370370
Logger.debug("Found %s attachments", attachments.size());
371371

372372
if (!attachments.isEmpty()) {
373-
boolean successfullyCreatedAttachmentDir = attachmentDir.mkdirs();
373+
if (!attachmentDir.exists()) {
374+
boolean successfullyCreatedAttachmentDir = attachmentDir.mkdirs();
374375

375-
if (!successfullyCreatedAttachmentDir) {
376-
throw new IllegalStateException("Failed to create attachment directory");
376+
if (!successfullyCreatedAttachmentDir) {
377+
throw new IllegalStateException("Failed to create attachment directory");
378+
}
377379
}
378380

379381
Logger.info("Extract attachments to %s", attachmentDir.getAbsolutePath());

0 commit comments

Comments
 (0)