Allow correcting inferred IDs (#103)

This commit is contained in:
Imran Remtulla
2023-06-23 11:52:49 -04:00
parent e0c4ec5028
commit 423ba07fad
4 changed files with 26 additions and 12 deletions

View File

@@ -202,16 +202,18 @@ class AppsProvider with ChangeNotifier {
// The former case should be handled (give the App its real ID), the latter is a security issue
if (app.id != newInfo.packageName) {
var isTempId = SourceProvider().isTempId(app);
if (apps[app.id] != null && !isTempId) {
throw IDChangedError();
if (apps[app.id] != null && !isTempId && !app.allowIdChange) {
throw IDChangedError(newInfo.packageName);
}
var idChangeWasAllowed = app.allowIdChange;
app.allowIdChange = false;
var originalAppId = app.id;
app.id = newInfo.packageName;
downloadedFile = downloadedFile.renameSync(
'${downloadedFile.parent.path}/${app.id}-${downloadUrl.hashCode}.${downloadedFile.path.split('.').last}');
if (apps[originalAppId] != null) {
await removeApps([originalAppId]);
await saveApps([app], onlyIfExists: !isTempId);
await saveApps([app], onlyIfExists: !isTempId && !idChangeWasAllowed);
}
}
return downloadedFile;