mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-05 12:24:26 +01:00
Auto optimize too many connections
This commit is contained in:
@@ -326,6 +326,9 @@ public interface DaoFolder {
|
||||
@Query("UPDATE folder SET tbd = 1 WHERE id = :id")
|
||||
int setFolderTbd(long id);
|
||||
|
||||
@Query("UPDATE folder SET poll = :poll, poll_count = 1 WHERE id = :id")
|
||||
int setFolderPoll(long id, boolean poll);
|
||||
|
||||
@Query("UPDATE folder SET poll_count = :count WHERE id = :id")
|
||||
int setFolderPollCount(long id, int count);
|
||||
|
||||
|
||||
@@ -1578,6 +1578,21 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
||||
" last connected: " + new Date(account.last_connected));
|
||||
if (errors >= FAST_ERROR_COUNT)
|
||||
state.setBackoff(FAST_ERROR_BACKOFF * 60);
|
||||
|
||||
boolean auto_optimize = prefs.getBoolean("auto_optimize", false);
|
||||
if (auto_optimize) {
|
||||
Throwable e = ex;
|
||||
while (e != null) {
|
||||
if (ConnectionHelper.isMaxConnections(e.getMessage())) {
|
||||
for (String ft : new String[]{EntityFolder.TRASH, EntityFolder.JUNK}) {
|
||||
EntityFolder f = db.folder().getFolderByType(account.id, ft);
|
||||
if (f != null)
|
||||
db.folder().setFolderPoll(f.id, true);
|
||||
}
|
||||
}
|
||||
e = e.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Report account connection error
|
||||
|
||||
Reference in New Issue
Block a user