fix: Download latest integrations non-pre-release

This commit is contained in:
oSumAtrIX 2024-04-28 23:40:28 +02:00
parent 7e0f18e3b7
commit 4a72267d41
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4
3 changed files with 10 additions and 66 deletions

View file

@ -23,39 +23,6 @@ class GithubAPI {
Future<Map<String, dynamic>?> getLatestRelease(
String repoName,
) async {
try {
final response = await _dio.get(
'/repos/$repoName/releases',
);
return response.data[0];
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
}
Future<Map<String, dynamic>?> getPatchesRelease(
String repoName,
String version,
) async {
try {
final response = await _dio.get(
'/repos/$repoName/releases/tags/$version',
);
return response.data;
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
}
Future<Map<String, dynamic>?> getLatestPatchesRelease(
String repoName,
) async {
try {
final response = await _dio.get(
@ -108,32 +75,7 @@ class GithubAPI {
}
}
Future<File?> getLatestReleaseFile(
String extension,
String repoName,
) async {
try {
final Map<String, dynamic>? release = await getLatestRelease(repoName);
if (release != null) {
final Map<String, dynamic>? asset =
(release['assets'] as List<dynamic>).firstWhereOrNull(
(asset) => (asset['name'] as String).endsWith(extension),
);
if (asset != null) {
return await _downloadManager.getSingleFile(
asset['browser_download_url'],
);
}
}
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
return null;
}
Future<File?> getPatchesReleaseFile(
Future<File?> getReleaseFile(
String extension,
String repoName,
String version,
@ -145,8 +87,10 @@ class GithubAPI {
url,
);
}
final Map<String, dynamic>? release =
await getPatchesRelease(repoName, version);
final response = await _dio.get(
'/repos/$repoName/releases/tags/$version',
);
final Map<String, dynamic>? release = response.data;
if (release != null) {
final Map<String, dynamic>? asset =
(release['assets'] as List<dynamic>).firstWhereOrNull(