Use onlyIfExists flag

This commit is contained in:
1xFF
2023-07-08 21:02:46 -07:00
parent bcc0d280ab
commit 7877a14f07

View File

@@ -787,8 +787,10 @@ class AppsProvider with ChangeNotifier {
if (attemptToCorrectInstallStatus) { if (attemptToCorrectInstallStatus) {
app = getCorrectedInstallStatusAppIfPossible(app, info) ?? app; app = getCorrectedInstallStatusAppIfPossible(app, info) ?? app;
} }
File('${(await getAppsDir()).path}/${app.id}.json') if (!onlyIfExists || this.apps.containsKey(app.id)) {
.writeAsStringSync(jsonEncode(app.toJson())); File('${(await getAppsDir()).path}/${app.id}.json')
.writeAsStringSync(jsonEncode(app.toJson()));
}
try { try {
this.apps.update( this.apps.update(
app.id, (value) => AppInMemory(app, value.downloadProgress, info), app.id, (value) => AppInMemory(app, value.downloadProgress, info),
@@ -902,7 +904,7 @@ class AppsProvider with ChangeNotifier {
if (currentApp.preferredApkIndex < newApp.apkUrls.length) { if (currentApp.preferredApkIndex < newApp.apkUrls.length) {
newApp.preferredApkIndex = currentApp.preferredApkIndex; newApp.preferredApkIndex = currentApp.preferredApkIndex;
} }
if (apps.containsKey(appId)) await saveApps([newApp]); await saveApps([newApp]);
return newApp.latestVersion != currentApp.latestVersion ? newApp : null; return newApp.latestVersion != currentApp.latestVersion ? newApp : null;
} }