1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-30 19:56:10 +00:00

Check message/attachment files on manual clean only

This commit is contained in:
M66B 2019-06-26 07:39:48 +02:00
parent 965dfdb84b
commit 1774a619e0

View file

@ -135,27 +135,29 @@ public class WorkerCleanup extends Worker {
Log.w("Error deleting " + file);
}
// Check message files
Log.i("Checking message files");
List<Long> mids = db.message().getMessageWithContent();
for (Long mid : mids) {
EntityMessage message = db.message().getMessage(mid);
File file = message.getFile(context);
if (!file.exists()) {
Log.w("Message file missing id=" + mid);
db.message().setMessageContent(mid, false);
if (manual) {
// Check message files
Log.i("Checking message files");
List<Long> mids = db.message().getMessageWithContent();
for (Long mid : mids) {
EntityMessage message = db.message().getMessage(mid);
File file = message.getFile(context);
if (!file.exists()) {
Log.w("Message file missing id=" + mid);
db.message().setMessageContent(mid, false);
}
}
}
// Check attachments files
Log.i("Checking attachments files");
List<Long> aids = db.attachment().getAttachmentAvailable();
for (Long aid : aids) {
EntityAttachment attachment = db.attachment().getAttachment(aid);
File file = attachment.getFile(context);
if (!file.exists()) {
Log.w("Attachment file missing id=" + aid);
db.attachment().setUnavailable(aid);
// Check attachments files
Log.i("Checking attachments files");
List<Long> aids = db.attachment().getAttachmentAvailable();
for (Long aid : aids) {
EntityAttachment attachment = db.attachment().getAttachment(aid);
File file = attachment.getFile(context);
if (!file.exists()) {
Log.w("Attachment file missing id=" + aid);
db.attachment().setUnavailable(aid);
}
}
}