prevent corrupt messages from breaking messenger loading

pull/62/head
Zlatin Balevsky 2021-06-03 12:54:00 +01:00
parent 6f3a3357ea
commit 34b7496036
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 11 additions and 7 deletions

View File

@ -123,6 +123,7 @@ class Messenger {
Files.walk(file.toPath()) Files.walk(file.toPath())
.filter({it.getFileName().toString().endsWith(".mwmessage")}) .filter({it.getFileName().toString().endsWith(".mwmessage")})
.forEach { Path path -> .forEach { Path path ->
try {
File f = path.toFile() File f = path.toFile()
MWMessage message MWMessage message
f.withInputStream { f.withInputStream {
@ -130,7 +131,10 @@ class Messenger {
} }
addMessage(message, dest) addMessage(message, dest)
File unread = new File(file, deriveUnread(message)) File unread = new File(file, deriveUnread(message))
eventBus.publish(new MessageLoadedEvent(message : message, folder : folder, unread : unread.exists())) eventBus.publish(new MessageLoadedEvent(message: message, folder: folder, unread: unread.exists()))
} catch (IOException iox) {
log.warning("couldn't load message from $path" )
}
} }
} }