mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50: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) {
|
public CachedMessage cacheMessage(SignalServiceEnvelope envelope, RecipientId recipientId) {
|
||||||
final var now = System.currentTimeMillis();
|
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 {
|
try {
|
||||||
var cacheFile = getMessageCacheFile(recipientId, now, envelope.getTimestamp());
|
|
||||||
MessageCacheUtils.storeEnvelope(envelope, cacheFile);
|
MessageCacheUtils.storeEnvelope(envelope, cacheFile);
|
||||||
return new CachedMessage(cacheFile, envelope);
|
return cachedMessage;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Failed to store encrypted message in disk cache, ignoring: {}", e.getMessage());
|
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