This commit is contained in:
otsmr 2025-05-01 23:03:59 +02:00
parent a7e57fd7d1
commit 7e7ac832e8
2 changed files with 8 additions and 5 deletions

View file

@ -321,17 +321,20 @@ Future<void> purgeMediaFiles(Directory directory) async {
final match = RegExp(r'(\d+)').firstMatch(filename); final match = RegExp(r'(\d+)').firstMatch(filename);
if (match != null) { if (match != null) {
// Parse the integer and add it to the list // Parse the integer and add it to the list
int messageId = int.parse(match.group(0)!); int fileId = int.parse(match.group(0)!);
Message? message = (directory.path.endsWith("send")) Message? message = (directory.path.endsWith("send"))
? await twonlyDatabase.messagesDao ? await twonlyDatabase.messagesDao
.getMessageByMediaUploadId(messageId) .getMessageByMediaUploadId(fileId)
.getSingleOrNull() .getSingleOrNull()
: await twonlyDatabase.messagesDao : await twonlyDatabase.messagesDao
.getMessageByMessageId(messageId) .getMessageByMessageId(fileId)
.getSingleOrNull(); .getSingleOrNull();
if ((message == null) || if ((message == null) ||
(message.openedAt != null && !message.mediaStored) || (message.openedAt != null &&
!message.mediaStored &&
message.acknowledgeByServer == true) ||
message.errorWhileSending) { message.errorWhileSending) {
try { try {
file.deleteSync(); file.deleteSync();

View file

@ -163,7 +163,7 @@ class ApiProvider {
Future<server.ServerToClient?> _waitForResponse(Int64 seq) async { Future<server.ServerToClient?> _waitForResponse(Int64 seq) async {
final startTime = DateTime.now(); final startTime = DateTime.now();
final timeout = Duration(seconds: 5); final timeout = Duration(seconds: 10);
while (true) { while (true) {
if (messagesV0[seq] != null) { if (messagesV0[seq] != null) {