fix(updater/nightly): remove old info when no update is available

This commit is contained in:
FineFindus
2023-04-20 15:51:47 +02:00
parent 6077bf4b55
commit d15d8a0169

View File

@@ -81,14 +81,7 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
MastodonApp.context.getSystemService(DownloadManager.class).remove(id); MastodonApp.context.getSystemService(DownloadManager.class).remove(id);
} }
getUpdateApkFile().delete(); getUpdateApkFile().delete();
getPrefs().edit() removeInfo();
.remove("apkSize")
.remove("version")
.remove("apkURL")
.remove("checkedByBuild")
.remove("downloadID")
.remove("changelog")
.apply();
} }
} }
@@ -154,6 +147,10 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
break; break;
} }
} }
} else {
Log.d(TAG, "actuallyCheckForUpdates: no update available");
removeInfo();
setState(UpdateState.NO_UPDATE);
} }
getPrefs().edit().putLong("lastCheck", System.currentTimeMillis()).apply(); getPrefs().edit().putLong("lastCheck", System.currentTimeMillis()).apply();
break; break;
@@ -165,6 +162,17 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
} }
} }
private void removeInfo() {
getPrefs().edit()
.remove("apkSize")
.remove("version")
.remove("apkURL")
.remove("checkedByBuild")
.remove("downloadID")
.remove("changelog")
.apply();
}
private void setState(UpdateState state){ private void setState(UpdateState state){
this.state=state; this.state=state;
E.post(new SelfUpdateStateChangedEvent(state)); E.post(new SelfUpdateStateChangedEvent(state));
@@ -212,7 +220,6 @@ public class GithubSelfUpdaterImpl extends GithubSelfUpdater{
} }
intent.setDataAndType(uri, "application/vnd.android.package-archive"); intent.setDataAndType(uri, "application/vnd.android.package-archive");
activity.startActivity(intent); activity.startActivity(intent);
setState(UpdateState.NO_UPDATE);
// TODO figure out how to restart the app when updating via this new API // TODO figure out how to restart the app when updating via this new API
/* /*