mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 12:58:34 +00:00
parent
44e845c875
commit
f68d99d16d
@ -519,15 +519,15 @@ public class AttachmentDatabase extends Database {
|
|||||||
if (database.update(TABLE_NAME, values, PART_ID_WHERE, attachmentId.toStrings()) == 0) {
|
if (database.update(TABLE_NAME, values, PART_ID_WHERE, attachmentId.toStrings()) == 0) {
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
dataInfo.file.delete();
|
dataInfo.file.delete();
|
||||||
|
} else {
|
||||||
|
notifyConversationListeners(DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(mmsId));
|
||||||
|
notifyConversationListListeners();
|
||||||
|
}
|
||||||
|
|
||||||
if (transferFile != null) {
|
if (transferFile != null) {
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
transferFile.delete();
|
transferFile.delete();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
notifyConversationListeners(DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(mmsId));
|
|
||||||
notifyConversationListListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
thumbnailExecutor.submit(new ThumbnailFetchCallable(attachmentId, STANDARD_THUMB_TIME));
|
thumbnailExecutor.submit(new ThumbnailFetchCallable(attachmentId, STANDARD_THUMB_TIME));
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
|||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
||||||
@ -114,8 +115,9 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||||||
private static final int ATTACHMENT_FILE_INDEX = 49;
|
private static final int ATTACHMENT_FILE_INDEX = 49;
|
||||||
private static final int STORAGE_SERVICE_ACTIVE = 50;
|
private static final int STORAGE_SERVICE_ACTIVE = 50;
|
||||||
private static final int GROUPS_V2_RECIPIENT_CAPABILITY = 51;
|
private static final int GROUPS_V2_RECIPIENT_CAPABILITY = 51;
|
||||||
|
private static final int TRANSFER_FILE_CLEANUP = 52;
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 51;
|
private static final int DATABASE_VERSION = 52;
|
||||||
private static final String DATABASE_NAME = "signal.db";
|
private static final String DATABASE_NAME = "signal.db";
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
@ -766,6 +768,28 @@ public class SQLCipherOpenHelper extends SQLiteOpenHelper {
|
|||||||
db.execSQL("ALTER TABLE recipient ADD COLUMN gv2_capability INTEGER DEFAULT 0");
|
db.execSQL("ALTER TABLE recipient ADD COLUMN gv2_capability INTEGER DEFAULT 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldVersion < TRANSFER_FILE_CLEANUP) {
|
||||||
|
File partsDirectory = context.getDir("parts", Context.MODE_PRIVATE);
|
||||||
|
|
||||||
|
if (partsDirectory.exists()) {
|
||||||
|
File[] transferFiles = partsDirectory.listFiles((dir, name) -> name.startsWith("transfer"));
|
||||||
|
int deleteCount = 0;
|
||||||
|
|
||||||
|
Log.i(TAG, "Found " + transferFiles.length + " dangling transfer files.");
|
||||||
|
|
||||||
|
for (File file : transferFiles) {
|
||||||
|
if (file.delete()) {
|
||||||
|
Log.i(TAG, "Deleted " + file.getName());
|
||||||
|
deleteCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.i(TAG, "Deleted " + deleteCount + " dangling transfer files.");
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "Part directory did not exist. Skipping.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
} finally {
|
} finally {
|
||||||
db.endTransaction();
|
db.endTransaction();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user