mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Use base64 group id for protobuf group file to match avatar files
base64 with '/' replaced by '_'
This commit is contained in:
parent
caabde4acf
commit
6a82029ab4
1 changed files with 17 additions and 2 deletions
|
@ -58,6 +58,10 @@ public class JsonGroupStore {
|
||||||
try (FileOutputStream stream = new FileOutputStream(getGroupFile(group.getGroupId()))) {
|
try (FileOutputStream stream = new FileOutputStream(getGroupFile(group.getGroupId()))) {
|
||||||
((GroupInfoV2) group).getGroup().writeTo(stream);
|
((GroupInfoV2) group).getGroup().writeTo(stream);
|
||||||
}
|
}
|
||||||
|
final File groupFileLegacy = getGroupFileLegacy(group.getGroupId());
|
||||||
|
if (groupFileLegacy.exists()) {
|
||||||
|
groupFileLegacy.delete();
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Failed to cache group, ignoring ...");
|
System.err.println("Failed to cache group, ignoring ...");
|
||||||
}
|
}
|
||||||
|
@ -95,17 +99,28 @@ public class JsonGroupStore {
|
||||||
|
|
||||||
private void loadDecryptedGroup(final GroupInfo group) {
|
private void loadDecryptedGroup(final GroupInfo group) {
|
||||||
if (group instanceof GroupInfoV2 && ((GroupInfoV2) group).getGroup() == null) {
|
if (group instanceof GroupInfoV2 && ((GroupInfoV2) group).getGroup() == null) {
|
||||||
try (FileInputStream stream = new FileInputStream(getGroupFile(group.getGroupId()))) {
|
File groupFile = getGroupFile(group.getGroupId());
|
||||||
|
if (!groupFile.exists()) {
|
||||||
|
groupFile = getGroupFileLegacy(group.getGroupId());
|
||||||
|
}
|
||||||
|
if (!groupFile.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try (FileInputStream stream = new FileInputStream(groupFile)) {
|
||||||
((GroupInfoV2) group).setGroup(DecryptedGroup.parseFrom(stream));
|
((GroupInfoV2) group).setGroup(DecryptedGroup.parseFrom(stream));
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getGroupFile(final GroupId groupId) {
|
private File getGroupFileLegacy(final GroupId groupId) {
|
||||||
return new File(groupCachePath, Hex.toStringCondensed(groupId.serialize()));
|
return new File(groupCachePath, Hex.toStringCondensed(groupId.serialize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File getGroupFile(final GroupId groupId) {
|
||||||
|
return new File(groupCachePath, groupId.toBase64().replace("/", "_"));
|
||||||
|
}
|
||||||
|
|
||||||
public GroupInfoV1 getOrCreateGroupV1(GroupIdV1 groupId) {
|
public GroupInfoV1 getOrCreateGroupV1(GroupIdV1 groupId) {
|
||||||
GroupInfo group = getGroup(groupId);
|
GroupInfo group = getGroup(groupId);
|
||||||
if (group instanceof GroupInfoV1) {
|
if (group instanceof GroupInfoV1) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue