mirror of
https://github.com/f-droid/fdroidclient.git
synced 2026-04-20 06:47:06 -04:00
[app] Make forceOldIndex preference work for forcing v1
in case there are severe bugs with v2 after it rolled out to users, so they can at least continue to receive updates with this setting.
This commit is contained in:
committed by
Hans-Christoph Steiner
parent
d512c909c3
commit
e5ebf7a218
@@ -199,10 +199,6 @@ public final class Preferences implements SharedPreferences.OnSharedPreferenceCh
|
||||
return preferences.getBoolean(PREF_FORCE_OLD_INDEX, IGNORED_B);
|
||||
}
|
||||
|
||||
public void setForceOldIndex(boolean flag) {
|
||||
preferences.edit().putBoolean(PREF_FORCE_OLD_INDEX, flag).apply();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to use the Privileged Installer, based on if it is installed. Only the disabled
|
||||
* state is stored as a preference since the enabled state is based entirely on the presence
|
||||
|
||||
@@ -58,7 +58,10 @@ import org.fdroid.fdroid.net.DownloaderFactory;
|
||||
import org.fdroid.index.IndexUpdateResult;
|
||||
import org.fdroid.index.RepoUpdater;
|
||||
import org.fdroid.index.RepoUriBuilder;
|
||||
import org.fdroid.index.TempFileProvider;
|
||||
import org.fdroid.index.v1.IndexV1Updater;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -439,9 +442,19 @@ public class UpdateService extends JobIntentService {
|
||||
final CompatibilityChecker compatChecker =
|
||||
new CompatibilityCheckerImpl(getPackageManager(), Preferences.get().forceTouchApps());
|
||||
final UpdateServiceListener listener = new UpdateServiceListener(UpdateService.this);
|
||||
final RepoUpdater repoUpdater = new RepoUpdater(getApplicationContext().getCacheDir(), db,
|
||||
DownloaderFactory.INSTANCE, repoUriBuilder, compatChecker, listener);
|
||||
final IndexUpdateResult result = repoUpdater.update(repo, fingerprint);
|
||||
final File cacheDir = getApplicationContext().getCacheDir();
|
||||
final IndexUpdateResult result;
|
||||
if (Preferences.get().isForceOldIndexEnabled()) {
|
||||
final TempFileProvider tempFileProvider = () ->
|
||||
File.createTempFile("dl-", "", cacheDir);
|
||||
final IndexV1Updater updater = new IndexV1Updater(db, tempFileProvider,
|
||||
DownloaderFactory.INSTANCE, repoUriBuilder, compatChecker, listener);
|
||||
result = updater.updateNewRepo(repo, fingerprint);
|
||||
} else {
|
||||
final RepoUpdater updater = new RepoUpdater(cacheDir, db,
|
||||
DownloaderFactory.INSTANCE, repoUriBuilder, compatChecker, listener);
|
||||
result = updater.update(repo, fingerprint);
|
||||
}
|
||||
if (result instanceof IndexUpdateResult.Unchanged) {
|
||||
unchangedRepos++;
|
||||
} else if (result instanceof IndexUpdateResult.Processed) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.fdroid.download.HttpDownloaderV2;
|
||||
import org.fdroid.download.HttpManager;
|
||||
import org.fdroid.download.Mirror;
|
||||
import org.fdroid.fdroid.FDroidApp;
|
||||
import org.fdroid.fdroid.Preferences;
|
||||
import org.fdroid.fdroid.Utils;
|
||||
import org.fdroid.index.IndexFormatVersion;
|
||||
|
||||
@@ -64,7 +65,10 @@ public class DownloaderFactory extends org.fdroid.download.DownloaderFactory {
|
||||
Proxy proxy = NetCipher.getProxy();
|
||||
DownloadRequest request = new DownloadRequest(indexFile, mirrors, proxy,
|
||||
repo.getUsername(), repo.getPassword(), tryFirst);
|
||||
if (repo.getFormatVersion() == null || repo.getFormatVersion() == IndexFormatVersion.ONE) {
|
||||
boolean oldIndex = Preferences.get().isForceOldIndexEnabled();
|
||||
boolean v1OrUnknown = repo.getFormatVersion() == null ||
|
||||
repo.getFormatVersion() == IndexFormatVersion.ONE;
|
||||
if (oldIndex || v1OrUnknown) {
|
||||
//noinspection deprecation
|
||||
downloader = new HttpDownloader(HTTP_MANAGER, request, destFile);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user