mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40: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 {
|
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");
|
JsonNode node = rootNode.get("deviceId");
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
|
@ -204,10 +208,12 @@ public class SignalAccount {
|
||||||
.putPOJO("threadStore", threadStore)
|
.putPOJO("threadStore", threadStore)
|
||||||
;
|
;
|
||||||
try {
|
try {
|
||||||
fileChannel.position(0);
|
synchronized (fileChannel) {
|
||||||
jsonProcessor.writeValue(Channels.newOutputStream(fileChannel), rootNode);
|
fileChannel.position(0);
|
||||||
fileChannel.truncate(fileChannel.position());
|
jsonProcessor.writeValue(Channels.newOutputStream(fileChannel), rootNode);
|
||||||
fileChannel.force(false);
|
fileChannel.truncate(fileChannel.position());
|
||||||
|
fileChannel.force(false);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println(String.format("Error saving file: %s", e.getMessage()));
|
System.err.println(String.format("Error saving file: %s", e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue