mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Improve message cache behavior in case of io error
This commit is contained in:
parent
0bdc400a30
commit
67747253e8
1 changed files with 11 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue