mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-04-19 21:39:16 +00:00
Fixed crash version check
This commit is contained in:
parent
92c8e4d103
commit
6196cd369a
1 changed files with 80 additions and 68 deletions
|
@ -2,19 +2,23 @@ bool compareVersions({
|
||||||
required String currentVersion,
|
required String currentVersion,
|
||||||
required String newVersion
|
required String newVersion
|
||||||
}) {
|
}) {
|
||||||
final currentSplit = currentVersion.split('.').map((e) => int.parse(e)).toList();
|
try {
|
||||||
final newSplit = newVersion.split('.').map((e) => int.parse(e)).toList();
|
final currentSplit = currentVersion.split('.').map((e) => int.parse(e)).toList();
|
||||||
|
final newSplit = newVersion.split('.').map((e) => int.parse(e)).toList();
|
||||||
|
|
||||||
if (newSplit[0] > currentSplit[0]) {
|
if (newSplit[0] > currentSplit[0]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (newSplit[1] > currentSplit[1]) {
|
else if (newSplit[1] > currentSplit[1]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (newSplit[2] > currentSplit[2]) {
|
else if (newSplit[2] > currentSplit[2]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,25 +27,29 @@ bool compareBetaVersions({
|
||||||
required String currentVersion,
|
required String currentVersion,
|
||||||
required String newVersion
|
required String newVersion
|
||||||
}) {
|
}) {
|
||||||
final currentSplit = currentVersion.split('-')[0].split('.').map((e) => int.parse(e)).toList();
|
try {
|
||||||
final newSplit = newVersion.split('-')[0].split('.').map((e) => int.parse(e)).toList();
|
final currentSplit = currentVersion.split('-')[0].split('.').map((e) => int.parse(e)).toList();
|
||||||
|
final newSplit = newVersion.split('-')[0].split('.').map((e) => int.parse(e)).toList();
|
||||||
|
|
||||||
final currentBeta = int.parse(currentVersion.split('-')[1].replaceAll('b.', ''));
|
final currentBeta = int.parse(currentVersion.split('-')[1].replaceAll('b.', ''));
|
||||||
final newBeta = int.parse(newVersion.split('-')[1].replaceAll('b.', ''));
|
final newBeta = int.parse(newVersion.split('-')[1].replaceAll('b.', ''));
|
||||||
|
|
||||||
if (newSplit[0] > currentSplit[0]) {
|
if (newSplit[0] > currentSplit[0]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (newSplit[1] > currentSplit[1]) {
|
else if (newSplit[1] > currentSplit[1]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (newSplit[2] > currentSplit[2]) {
|
else if (newSplit[2] > currentSplit[2]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (newBeta > currentBeta) {
|
else if (newBeta > currentBeta) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,19 +59,47 @@ bool serverVersionIsAhead({
|
||||||
required String referenceVersion,
|
required String referenceVersion,
|
||||||
String? referenceVersionBeta
|
String? referenceVersionBeta
|
||||||
}) {
|
}) {
|
||||||
final current = currentVersion.replaceAll('v', '');
|
try {
|
||||||
final reference = referenceVersion.replaceAll('v', '');
|
final current = currentVersion.replaceAll('v', '');
|
||||||
final referenceBeta = referenceVersionBeta?.replaceAll('v', '');
|
final reference = referenceVersion.replaceAll('v', '');
|
||||||
|
final referenceBeta = referenceVersionBeta?.replaceAll('v', '');
|
||||||
|
|
||||||
if (current.contains('beta')) {
|
if (current.contains('b')) {
|
||||||
if (referenceBeta != null) {
|
if (referenceBeta != null) {
|
||||||
final currentSplit = current.split('-')[0].split('.').map((e) => int.parse(e)).toList();
|
final currentSplit = current.split('-')[0].split('.').map((e) => int.parse(e)).toList();
|
||||||
final newSplit = referenceBeta.split('-')[0].split('.').map((e) => int.parse(e)).toList();
|
final newSplit = referenceBeta.split('-')[0].split('.').map((e) => int.parse(e)).toList();
|
||||||
|
|
||||||
final currentBeta = int.parse(current.split('-')[1].replaceAll('b.', ''));
|
final currentBeta = int.parse(current.split('-')[1].replaceAll('b.', ''));
|
||||||
final newBeta = int.parse(referenceBeta.split('-')[1].replaceAll('b.', ''));
|
final newBeta = int.parse(referenceBeta.split('-')[1].replaceAll('b.', ''));
|
||||||
|
|
||||||
if (newSplit[0] == currentSplit[0] && newSplit[1] == currentSplit[1] && newSplit[2] == currentSplit[2] && newBeta == currentBeta) {
|
if (newSplit[0] == currentSplit[0] && newSplit[1] == currentSplit[1] && newSplit[2] == currentSplit[2] && newBeta == currentBeta) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (newSplit[0] < currentSplit[0]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (newSplit[1] < currentSplit[1]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (newSplit[2] < currentSplit[2]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (newBeta < currentBeta) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final currentSplit = current.split('.').map((e) => int.parse(e)).toList();
|
||||||
|
final newSplit = reference.split('.').map((e) => int.parse(e)).toList();
|
||||||
|
|
||||||
|
if (newSplit[0] == currentSplit[0] && newSplit[1] == currentSplit[1] && newSplit[2] == currentSplit[2]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (newSplit[0] < currentSplit[0]) {
|
else if (newSplit[0] < currentSplit[0]) {
|
||||||
|
@ -75,35 +111,11 @@ bool serverVersionIsAhead({
|
||||||
else if (newSplit[2] < currentSplit[2]) {
|
else if (newSplit[2] < currentSplit[2]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (newBeta < currentBeta) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
final currentSplit = current.split('.').map((e) => int.parse(e)).toList();
|
|
||||||
final newSplit = reference.split('.').map((e) => int.parse(e)).toList();
|
|
||||||
|
|
||||||
if (newSplit[0] == currentSplit[0] && newSplit[1] == currentSplit[1] && newSplit[2] == currentSplit[2]) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (newSplit[0] < currentSplit[0]) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (newSplit[1] < currentSplit[1]) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (newSplit[2] < currentSplit[2]) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue