Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes _shouldUpdate Algorithm #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

undreeyyy
Copy link

bool _shouldUpdate(String? packageVersion, String? storeVersion) {
if (packageVersion == storeVersion) return false;
final arr1 = packageVersion!.split('.');
final arr2 = storeVersion!.split('.');
for (int i = 0; i < math.min(arr1.length, arr2.length); i++) {
int? v1 = int.tryParse(arr1[i]);
int? v2 = int.tryParse(arr2[i]);
if (v1 == null || v2 == null) {
if (arr2[i].compareTo(arr1[i]) > 0) {
return true;
}
} else if (v2 > v1) {
return true;
}
}
return false;
}

Line 177 - 178 is faulty. This will return true when storeVersion is 5.1.1 and packageVersion is 6.0.0.

My fix will convert the given version from a string to an integer. Such that '6.0.0' will be 600 and '5.1.1' will be 511. Then comparing the 2 integers we can identify the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant