prevent deadlock in case auto feed update is blocked per review.

This commit is contained in:
orionlee 2019-09-01 09:46:25 -07:00
parent 907867652f
commit 366146d22e
1 changed files with 2 additions and 2 deletions

View File

@ -34,13 +34,13 @@ public class FeedUpdateWorker extends Worker {
Log.d(TAG, "doWork() : isImmediate = " + isImmediate); Log.d(TAG, "doWork() : isImmediate = " + isImmediate);
ClientConfig.initialize(getApplicationContext()); ClientConfig.initialize(getApplicationContext());
AtomicBoolean finished = new AtomicBoolean(false);
if (NetworkUtils.networkAvailable() && NetworkUtils.isFeedRefreshAllowed()) { if (NetworkUtils.networkAvailable() && NetworkUtils.isFeedRefreshAllowed()) {
AtomicBoolean finished = new AtomicBoolean(false);
DBTasks.refreshAllFeeds(getApplicationContext(), null, () -> finished.set(true)); DBTasks.refreshAllFeeds(getApplicationContext(), null, () -> finished.set(true));
Awaitility.await().until(finished::get);
} else { } else {
Log.d(TAG, "Blocking automatic update: no wifi available / no mobile updates allowed"); Log.d(TAG, "Blocking automatic update: no wifi available / no mobile updates allowed");
} }
Awaitility.await().until(finished::get);
if (!isImmediate && UserPreferences.isAutoUpdateTimeOfDay()) { if (!isImmediate && UserPreferences.isAutoUpdateTimeOfDay()) {
// WorkManager does not allow to set specific time for repeated tasks. // WorkManager does not allow to set specific time for repeated tasks.