mirror of https://github.com/M66B/FairEmail.git
Fixed/improved cleanup
This commit is contained in:
parent
8655d3bb7c
commit
00049edd12
|
@ -113,6 +113,7 @@ public class WorkerCleanup extends Worker {
|
|||
// Check message files
|
||||
Log.i("Checking message files");
|
||||
try (Cursor cursor = db.message().getMessageWithContent()) {
|
||||
while (cursor.moveToNext()) {
|
||||
long mid = cursor.getLong(0);
|
||||
EntityMessage message = db.message().getMessage(mid);
|
||||
if (message != null) {
|
||||
|
@ -123,10 +124,12 @@ public class WorkerCleanup extends Worker {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check attachments files
|
||||
Log.i("Checking attachments files");
|
||||
try (Cursor cursor = db.attachment().getAttachmentAvailable()) {
|
||||
while (cursor.moveToNext()) {
|
||||
long aid = cursor.getLong(0);
|
||||
EntityAttachment attachment = db.attachment().getAttachment(aid);
|
||||
if (attachment != null) {
|
||||
|
@ -137,6 +140,7 @@ public class WorkerCleanup extends Worker {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete old attachments
|
||||
if (cleanup_attachments) {
|
||||
|
@ -211,6 +215,15 @@ public class WorkerCleanup extends Worker {
|
|||
|
||||
// Cleanup message files
|
||||
Log.breadcrumb("worker", "cleanup", "message files");
|
||||
{
|
||||
File[] files = new File(context.getFilesDir(), "messages").listFiles();
|
||||
for (File file : files) {
|
||||
if (file.isDirectory())
|
||||
cleanupMessageFiles(db, manual, file.listFiles());
|
||||
else
|
||||
cleanupMessageFiles(db, manual, new File[]{file});
|
||||
}
|
||||
}
|
||||
cleanupMessageFiles(db, manual, Helper.listFiles(new File(context.getFilesDir(), "messages")).toArray(new File[0]));
|
||||
cleanupMessageFiles(db, manual, new File(context.getFilesDir(), "revision").listFiles());
|
||||
cleanupMessageFiles(db, manual, new File(context.getFilesDir(), "references").listFiles());
|
||||
|
|
Loading…
Reference in New Issue