Browse Source

Auto download attachments < 32 KB

Fixes #81
main
M66B 5 years ago
parent
commit
78ad5f14b0
2 changed files with 9 additions and 0 deletions
  1. +2
    -0
      app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java
  2. +7
    -0
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 2
- 0
app/src/main/java/eu/faircode/email/BoundaryCallbackMessages.java View File

@ -169,6 +169,8 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
index--;
}
EntityOperation.process(context); // download small attachments
Log.i(Helper.TAG, "Boundary done");
} catch (final Throwable ex) {
Log.e(Helper.TAG, "Boundary " + ex + "\n" + Log.getStackTraceString(ex));


+ 7
- 0
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -124,6 +124,7 @@ public class ServiceSynchronize extends LifecycleService {
private static final int CONNECT_BACKOFF_START = 32; // seconds
private static final int CONNECT_BACKOFF_MAX = 1024; // seconds (1024 sec ~ 17 min)
private static final long STORE_NOOP_INTERVAL = 9 * 60 * 1000L; // ms
private static final int ATTACHMENT_AUTO_DOWNLOAD_SIZE = 32 * 1024; // bytes
static final String ACTION_SYNCHRONIZE_FOLDER = BuildConfig.APPLICATION_ID + ".SYNCHRONIZE_FOLDER";
static final String ACTION_PROCESS_OPERATIONS = BuildConfig.APPLICATION_ID + ".PROCESS_OPERATIONS";
@ -519,6 +520,7 @@ public class ServiceSynchronize extends LifecycleService {
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
}
EntityOperation.process(ServiceSynchronize.this); // download small attachments
} catch (Throwable ex) {
Log.e(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
reportError(account.name, folder.name, ex);
@ -576,6 +578,7 @@ public class ServiceSynchronize extends LifecycleService {
try {
Log.i(Helper.TAG, folder.name + " message changed");
synchronizeMessage(ServiceSynchronize.this, folder, ifolder, (IMAPMessage) e.getMessage(), false);
EntityOperation.process(ServiceSynchronize.this); // download small attachments
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
}
@ -1265,6 +1268,7 @@ public class ServiceSynchronize extends LifecycleService {
} catch (MessageRemovedException ex) {
Log.w(Helper.TAG, folder.name + " " + ex + "\n" + Log.getStackTraceString(ex));
}
EntityOperation.process(this); // download small attachments
Log.w(Helper.TAG, folder.name + " statistics added=" + added + " updated=" + updated + " unchanged=" + unchanged);
} finally {
@ -1393,6 +1397,9 @@ public class ServiceSynchronize extends LifecycleService {
attachment.message = message.id;
attachment.sequence = sequence;
attachment.id = db.attachment().insertAttachment(attachment);
if (attachment.size != null && attachment.size < ATTACHMENT_AUTO_DOWNLOAD_SIZE)
EntityOperation.queue(db, message, EntityOperation.ATTACHMENT, sequence);
}
result = 1;


Loading…
Cancel
Save