Skip to content

Commit

Permalink
Add additional logging around attachment upload/deletion.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Oct 22, 2019
1 parent cee6736 commit b281b81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/org/thoughtcrime/securesms/database/AttachmentDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ public boolean hasAttachmentFilesForMessage(long mmsId) {

@SuppressWarnings("ResultOfMethodCallIgnored")
public void deleteAttachmentsForMessage(long mmsId) {
Log.d(TAG, "[deleteAttachmentsForMessage] mmsId: " + mmsId);

SQLiteDatabase database = databaseHelper.getWritableDatabase();
Cursor cursor = null;

Expand All @@ -317,6 +319,8 @@ public void deleteAttachmentsForMessage(long mmsId) {
}

public void deleteAttachmentFilesForMessage(long mmsId) {
Log.d(TAG, "[deleteAttachmentFilesForMessage] mmsId: " + mmsId);

SQLiteDatabase database = databaseHelper.getWritableDatabase();
Cursor cursor = null;

Expand Down Expand Up @@ -360,6 +364,8 @@ public void deleteAttachmentFilesForMessage(long mmsId) {


public void deleteAttachment(@NonNull AttachmentId id) {
Log.d(TAG, "[deleteAttachment] attachmentId: " + id);

SQLiteDatabase database = databaseHelper.getWritableDatabase();

try (Cursor cursor = database.query(TABLE_NAME,
Expand Down Expand Up @@ -408,9 +414,9 @@ private void deleteAttachmentOnDisk(@Nullable String data,
boolean dataInUse = isDataUsedByAnotherAttachment(data, attachmentId);

if (dataInUse) {
Log.i(TAG, "[deleteAttachmentOnDisk] Attachment in use. Skipping deletion. " + data);
Log.i(TAG, "[deleteAttachmentOnDisk] Attachment in use. Skipping deletion. " + data + " " + attachmentId);
} else {
Log.i(TAG, "[deleteAttachmentOnDisk] No other users of this attachment. Safe to delete. " + data);
Log.i(TAG, "[deleteAttachmentOnDisk] No other users of this attachment. Safe to delete. " + data + " " + attachmentId);
}

if (!TextUtils.isEmpty(data) && !dataInUse) {
Expand Down
2 changes: 2 additions & 0 deletions src/org/thoughtcrime/securesms/jobs/AttachmentUploadJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public void onRun() throws Exception {
throw new InvalidAttachmentException("Cannot find the specified attachment.");
}

Log.i(TAG, "Uploading attachment for message " + databaseAttachment.getMmsId() + " with ID " + databaseAttachment.getAttachmentId());

try (NotificationController notification = getNotificationForAttachment(databaseAttachment)) {
SignalServiceAttachment localAttachment = getAttachmentFor(databaseAttachment, notification);
SignalServiceAttachmentPointer remoteAttachment = messageSender.uploadAttachment(localAttachment.asStream());
Expand Down

0 comments on commit b281b81

Please sign in to comment.