Cleanup on delete local messages

pull/194/merge
M66B 3 years ago
parent 33fc453cb8
commit 9073183ef3

@ -950,6 +950,8 @@ public class FragmentFolders extends FragmentBase {
db.endTransaction();
}
WorkerCleanup.cleanup(context, false);
return null;
}

@ -40,6 +40,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import io.requery.android.database.sqlite.SQLiteDatabase;
@ -52,6 +53,8 @@ public class WorkerCleanup extends Worker {
private static final long KEEP_IMAGES_DURATION = 3 * 24 * 3600 * 1000L; // milliseconds
private static final long KEEP_CONTACTS_DURATION = 180 * 24 * 3600 * 1000L; // milliseconds
private static Semaphore semaphore = new Semaphore(1);
public WorkerCleanup(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
Log.i("Instance " + getName());
@ -98,6 +101,7 @@ public class WorkerCleanup extends Worker {
long start = new Date().getTime();
DB db = DB.getInstance(context);
try {
semaphore.acquire();
EntityLog.log(context, "Start cleanup manual=" + manual);
if (manual) {
@ -364,6 +368,7 @@ public class WorkerCleanup extends Worker {
} catch (Throwable ex) {
Log.e(ex);
} finally {
semaphore.release();
EntityLog.log(context, "End cleanup=" + (new Date().getTime() - start) + " ms");
long now = new Date().getTime();

Loading…
Cancel
Save