}
break;
case REQUEST_INFO:
- try {
- sendUpdateGroupMessage(groupInfo.getGroupId(), source);
- } catch (IOException | EncapsulatedExceptions e) {
- e.printStackTrace();
+ if (group != null) {
+ try {
+ sendUpdateGroupMessage(groupInfo.getGroupId(), source);
+ } catch (IOException | EncapsulatedExceptions e) {
+ e.printStackTrace();
+ } catch (NotAGroupMemberException e) {
+ // We have left this group, so don't send a group update message
+ }
}
break;
}
if (output != null) {
output.close();
}
+ input.close();
if (!tmpFile.delete()) {
System.err.println("Failed to delete temp file: " + tmpFile);
}
if (groupsFile.exists() && groupsFile.length() > 0) {
FileInputStream contactsFileStream = new FileInputStream(groupsFile);
- SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
- .withStream(contactsFileStream)
- .withContentType("application/octet-stream")
- .withLength(groupsFile.length())
- .build();
-
- sendSyncMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
+ try {
+ SignalServiceAttachmentStream attachmentStream = SignalServiceAttachment.newStreamBuilder()
+ .withStream(contactsFileStream)
+ .withContentType("application/octet-stream")
+ .withLength(groupsFile.length())
+ .build();
+
+ sendSyncMessage(SignalServiceSyncMessage.forGroups(attachmentStream));
+ } finally {
+ contactsFileStream.close();
+ }
}
} finally {
groupsFile.delete();