mirror of https://github.com/M66B/FairEmail.git
Check storage space on logging
This commit is contained in:
parent
ef2fcf5e33
commit
6bf6cb1d84
|
@ -39,7 +39,10 @@ import java.util.concurrent.ExecutorService;
|
|||
)
|
||||
public class EntityLog {
|
||||
static final String TABLE_NAME = "log";
|
||||
static Long last_cleanup = null;
|
||||
|
||||
private static boolean ok = true;
|
||||
private static long count = 0;
|
||||
private static Long last_cleanup = null;
|
||||
|
||||
private static final long LOG_CLEANUP_INTERVAL = 3600 * 1000L; // milliseconds
|
||||
private static final long LOG_KEEP_DURATION = 24 * 3600 * 1000L; // milliseconds
|
||||
|
@ -67,6 +70,13 @@ public class EntityLog {
|
|||
executor.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!ok || (++count % LOG_DELETE_BATCH_SIZE) == 0) {
|
||||
long cake = Helper.getAvailableStorageSpace();
|
||||
ok = (cake < Helper.MIN_REQUIRED_SPACE);
|
||||
if (!ok)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
try {
|
||||
db.beginTransaction();
|
||||
db.log().insertLog(entry);
|
||||
|
|
|
@ -146,6 +146,7 @@ public class Helper {
|
|||
static final float LOW_LIGHT = 0.6f;
|
||||
|
||||
static final int BUFFER_SIZE = 8192; // Same as in Files class
|
||||
static final long MIN_REQUIRED_SPACE = 250 * 1024L * 1024L;
|
||||
|
||||
static final String PGP_BEGIN_MESSAGE = "-----BEGIN PGP MESSAGE-----";
|
||||
static final String PGP_END_MESSAGE = "-----END PGP MESSAGE-----";
|
||||
|
|
|
@ -124,7 +124,6 @@ public class MessageHelper {
|
|||
private static final long ATTACHMENT_PROGRESS_UPDATE = 1500L; // milliseconds
|
||||
private static final int MAX_META_EXCERPT = 1024; // characters
|
||||
private static final int FORMAT_FLOWED_LINE_LENGTH = 72;
|
||||
private static final long MIN_REQUIRED_SPACE = 250 * 1024L * 1024L;
|
||||
|
||||
private static final List<Charset> CHARSET16 = Collections.unmodifiableList(Arrays.asList(
|
||||
StandardCharsets.UTF_16,
|
||||
|
@ -801,7 +800,7 @@ public class MessageHelper {
|
|||
|
||||
MessageHelper(MimeMessage message, Context context) throws IOException {
|
||||
long cake = Helper.getAvailableStorageSpace();
|
||||
if (cake < MIN_REQUIRED_SPACE)
|
||||
if (cake < Helper.MIN_REQUIRED_SPACE)
|
||||
throw new IOException(context.getString(R.string.app_cake));
|
||||
if (cacheDir == null)
|
||||
cacheDir = context.getCacheDir();
|
||||
|
|
Loading…
Reference in New Issue