[app] Don't update repos twice on fresh start

DbHelper#prePopulateDb() is already kicking off an index update, so MainActivity doesn't need to anymore.
This commit is contained in:
Torsten Grote
2024-10-23 11:24:40 -03:00
parent 2c7e797ed3
commit d8a287ae97
3 changed files with 3 additions and 12 deletions

View File

@@ -363,6 +363,7 @@ public class FDroidApp extends Application implements androidx.work.Configuratio
// force setting network state to ensure it is set before UpdateService checks it
networkState = ConnectivityMonitorService.getNetworkState(this);
ConnectivityMonitorService.registerAndStart(this);
Utils.debugLog(TAG, "RepoUpdateWorker.scheduleOrCancel()");
RepoUpdateWorker.scheduleOrCancel(getApplicationContext());
FDroidApp.initWifiSettings();

View File

@@ -57,7 +57,6 @@ import org.fdroid.fdroid.nearby.TreeUriScannerIntentService;
import org.fdroid.fdroid.nearby.WifiStateChangeService;
import org.fdroid.fdroid.views.AppDetailsActivity;
import org.fdroid.fdroid.views.apps.AppListActivity;
import org.fdroid.fdroid.work.RepoUpdateWorker;
/**
* Main view shown to users upon starting F-Droid.
@@ -141,8 +140,6 @@ public class MainActivity extends AppCompatActivity {
updatesBadge = bottomNavigation.getOrCreateBadge(R.id.updates);
updatesBadge.setVisible(false);
initialRepoUpdateIfRequired();
AppUpdateStatusManager.getInstance(this).getNumUpdatableApps().observe(this, this::refreshUpdatesBadge);
Intent intent = getIntent();
@@ -181,14 +178,6 @@ public class MainActivity extends AppCompatActivity {
}
}
private void initialRepoUpdateIfRequired() {
if (Preferences.get().isIndexNeverUpdated() &&
!FDroidApp.getRepoUpdateManager(this).isUpdating().getValue()) {
Utils.debugLog(TAG, "We haven't done an update yet. Forcing repo update.");
RepoUpdateWorker.updateNow(this);
}
}
@Override
protected void onResume() {
super.onResume();
@@ -407,4 +396,4 @@ public class MainActivity extends AppCompatActivity {
return false;
}
}
}
}

View File

@@ -80,6 +80,7 @@ class RepoUpdateWorker(
val doUpdateChecks = prefs.updateInterval != UPDATE_INTERVAL_DISABLED &&
!(prefs.overData == OVER_NETWORK_NEVER && prefs.overWifi == OVER_NETWORK_NEVER)
if (doUpdateChecks) {
Log.i(TAG, "scheduleOrCancel: enqueueUniquePeriodicWork")
val networkType = if (prefs.overData == OVER_NETWORK_ALWAYS &&
prefs.overWifi == OVER_NETWORK_ALWAYS
) {