mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
parent
8c295a3f90
commit
e36a54e7cc
1 changed files with 11 additions and 5 deletions
|
@ -129,7 +129,11 @@ public class SignalAccount {
|
|||
}
|
||||
|
||||
private void load() throws IOException {
|
||||
JsonNode rootNode = jsonProcessor.readTree(Channels.newInputStream(fileChannel));
|
||||
JsonNode rootNode;
|
||||
synchronized (fileChannel) {
|
||||
fileChannel.position(0);
|
||||
rootNode = jsonProcessor.readTree(Channels.newInputStream(fileChannel));
|
||||
}
|
||||
|
||||
JsonNode node = rootNode.get("deviceId");
|
||||
if (node != null) {
|
||||
|
@ -204,10 +208,12 @@ public class SignalAccount {
|
|||
.putPOJO("threadStore", threadStore)
|
||||
;
|
||||
try {
|
||||
fileChannel.position(0);
|
||||
jsonProcessor.writeValue(Channels.newOutputStream(fileChannel), rootNode);
|
||||
fileChannel.truncate(fileChannel.position());
|
||||
fileChannel.force(false);
|
||||
synchronized (fileChannel) {
|
||||
fileChannel.position(0);
|
||||
jsonProcessor.writeValue(Channels.newOutputStream(fileChannel), rootNode);
|
||||
fileChannel.truncate(fileChannel.position());
|
||||
fileChannel.force(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println(String.format("Error saving file: %s", e.getMessage()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue