mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add additional logging for reading message cache
This commit is contained in:
parent
9da42e27f1
commit
316c35b258
2 changed files with 11 additions and 3 deletions
|
@ -27,7 +27,7 @@ public final class CachedMessage {
|
||||||
try {
|
try {
|
||||||
return MessageCacheUtils.loadEnvelope(file);
|
return MessageCacheUtils.loadEnvelope(file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Failed to load cached message envelope “{}”: {}", file, e.getMessage());
|
logger.error("Failed to load cached message envelope “{}”: {}", file, e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.asamk.signal.manager.util;
|
package org.asamk.signal.manager.util;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
|
@ -15,11 +17,17 @@ import java.util.Optional;
|
||||||
|
|
||||||
public class MessageCacheUtils {
|
public class MessageCacheUtils {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(MessageCacheUtils.class);
|
||||||
|
|
||||||
|
final static int CURRENT_VERSION = 8;
|
||||||
|
|
||||||
public static SignalServiceEnvelope loadEnvelope(File file) throws IOException {
|
public static SignalServiceEnvelope loadEnvelope(File file) throws IOException {
|
||||||
try (var f = new FileInputStream(file)) {
|
try (var f = new FileInputStream(file)) {
|
||||||
var in = new DataInputStream(f);
|
var in = new DataInputStream(f);
|
||||||
var version = in.readInt();
|
var version = in.readInt();
|
||||||
if (version > 8) {
|
logger.trace("Reading cached envelope file with version {} (current: {})", version, CURRENT_VERSION);
|
||||||
|
if (version > CURRENT_VERSION) {
|
||||||
|
logger.warn("Unsupported envelope version {} (current: {})", version, CURRENT_VERSION);
|
||||||
// Unsupported envelope version
|
// Unsupported envelope version
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +104,7 @@ public class MessageCacheUtils {
|
||||||
public static void storeEnvelope(SignalServiceEnvelope envelope, File file) throws IOException {
|
public static void storeEnvelope(SignalServiceEnvelope envelope, File file) throws IOException {
|
||||||
try (var f = new FileOutputStream(file)) {
|
try (var f = new FileOutputStream(file)) {
|
||||||
try (var out = new DataOutputStream(f)) {
|
try (var out = new DataOutputStream(f)) {
|
||||||
out.writeInt(8); // version
|
out.writeInt(CURRENT_VERSION); // version
|
||||||
out.writeInt(envelope.getType());
|
out.writeInt(envelope.getType());
|
||||||
out.writeUTF(""); // legacy number
|
out.writeUTF(""); // legacy number
|
||||||
out.writeUTF(envelope.getSourceUuid().isPresent() ? envelope.getSourceUuid().get() : "");
|
out.writeUTF(envelope.getSourceUuid().isPresent() ? envelope.getSourceUuid().get() : "");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue