mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-21 13:47:04 +00:00
Auto optimize too many connections
This commit is contained in:
parent
81105e7055
commit
2f09afedac
3 changed files with 23 additions and 2 deletions
7
FAQ.md
7
FAQ.md
|
@ -1416,13 +1416,16 @@ consider switching to a modern provider which supports push messages (IMAP IDLE)
|
|||
If your device has an [AMOLED](https://en.wikipedia.org/wiki/AMOLED) screen,
|
||||
you can save battery usage while viewing messages by switching to the black theme.
|
||||
|
||||
By default auto optimize in the receive settings is enabled,
|
||||
which will switch an account to periodically checking for new messages when the email server:
|
||||
If auto optimize in the receive settings is enabled,
|
||||
an account will automatically be switched to periodically checking for new messages when the email server:
|
||||
|
||||
* Says '*Still here*' within 3 minutes
|
||||
* The email server does not support push messages
|
||||
* The keep-alive interval is lower than 12 minutes
|
||||
|
||||
In addition, the trash and spam folders will be automatically set to checking for new messages
|
||||
after three successive [too many simultaneous connections](#user-content-faq23) errors.
|
||||
|
||||
<br />
|
||||
|
||||
<a name="faq40"></a>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue