diff --git a/lib/src/main/java/org/asamk/signal/manager/storage/messageCache/MessageCache.java b/lib/src/main/java/org/asamk/signal/manager/storage/messageCache/MessageCache.java index e78928a8..30452fbb 100644 --- a/lib/src/main/java/org/asamk/signal/manager/storage/messageCache/MessageCache.java +++ b/lib/src/main/java/org/asamk/signal/manager/storage/messageCache/MessageCache.java @@ -51,13 +51,21 @@ public class MessageCache { public CachedMessage cacheMessage(SignalServiceEnvelope envelope, RecipientId recipientId) { final var now = System.currentTimeMillis(); + File cacheFile; + try { + cacheFile = getMessageCacheFile(recipientId, now, envelope.getTimestamp()); + } catch (IOException e) { + logger.warn("Failed to create recipient folder in disk cache: {}", e.getMessage()); + throw new RuntimeException(e); + } + + final var cachedMessage = new CachedMessage(cacheFile, envelope); try { - var cacheFile = getMessageCacheFile(recipientId, now, envelope.getTimestamp()); MessageCacheUtils.storeEnvelope(envelope, cacheFile); - return new CachedMessage(cacheFile, envelope); + return cachedMessage; } catch (IOException e) { logger.warn("Failed to store encrypted message in disk cache, ignoring: {}", e.getMessage()); - return null; + return cachedMessage; } }