diff --git a/backend/src/api/package.rs b/backend/src/api/package.rs index ed2f9c1..78723f5 100644 --- a/backend/src/api/package.rs +++ b/backend/src/api/package.rs @@ -35,11 +35,7 @@ pub async fn package_add( // remove leading and trailing whitespaces let pkg_name = input.name.trim(); - let pkg = get_info_by_name(pkg_name) - .await - .map_err(|_| BadRequest(Some("couldn't download package metadata".to_string())))?; - - if let None = Packages::find() + if let Some(..) = Packages::find() .filter(packages::Column::Name.eq(pkg_name)) .one(db) .await @@ -48,6 +44,10 @@ pub async fn package_add( return Err(BadRequest(Some("Package already exists".to_string()))); } + let pkg = get_info_by_name(pkg_name) + .await + .map_err(|_| BadRequest(Some("couldn't download package metadata".to_string())))?; + let mut new_package = packages::ActiveModel { name: Set(pkg_name.to_string()), status: Set(3), diff --git a/backend/src/api/remove.rs b/backend/src/api/remove.rs index 911449d..802550c 100644 --- a/backend/src/api/remove.rs +++ b/backend/src/api/remove.rs @@ -1,4 +1,4 @@ -use crate::repo::repo::{remove_pkg, remove_version}; +use crate::repo::repo::{remove_version}; use rocket::{post, State}; use rocket_okapi::openapi; use sea_orm::DatabaseConnection; diff --git a/frontend/lib/api/api_client.dart b/frontend/lib/api/api_client.dart index dd0e9d8..bcea026 100644 --- a/frontend/lib/api/api_client.dart +++ b/frontend/lib/api/api_client.dart @@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart'; class ApiClient { static const String _apiBase = - kDebugMode ? "http://localhost:8081/api" : "api"; + kDebugMode ? "https://aurcache.heili.eu/api" : "api"; final Dio _dio = Dio(BaseOptions(baseUrl: _apiBase)); String? token; diff --git a/frontend/lib/components/api/APIBuilder.dart b/frontend/lib/components/api/APIBuilder.dart index 033549f..e69e701 100644 --- a/frontend/lib/components/api/APIBuilder.dart +++ b/frontend/lib/components/api/APIBuilder.dart @@ -43,7 +43,7 @@ class _APIBuilderState if (widget.interval != null) { timer = Timer.periodic(widget.interval!, (Timer t) { Provider.of(context, listen: false) - .refresh(context, dto: widget.dto); + .refresh(context); }); } } diff --git a/frontend/lib/providers/BaseProvider.dart b/frontend/lib/providers/BaseProvider.dart index c2ca658..ac57716 100644 --- a/frontend/lib/providers/BaseProvider.dart +++ b/frontend/lib/providers/BaseProvider.dart @@ -2,11 +2,12 @@ import 'package:flutter/material.dart'; abstract class BaseProvider with ChangeNotifier { late Future data; + DTO? dto; loadFuture(context, {DTO? dto}); - refresh(context, {DTO? dto}) { - loadFuture(context, dto: dto); + refresh(context) { + loadFuture(context, dto: this.dto); notifyListeners(); } } diff --git a/frontend/lib/providers/aur_search_provider.dart b/frontend/lib/providers/aur_search_provider.dart index fbf1c81..da8a87e 100644 --- a/frontend/lib/providers/aur_search_provider.dart +++ b/frontend/lib/providers/aur_search_provider.dart @@ -14,5 +14,6 @@ class AURSearchProvider extends BaseProvider, AurSearchDTO> { @override loadFuture(context, {dto}) { data = API.getAurPackages(dto!.query); + this.dto = dto; } } diff --git a/frontend/lib/providers/build_provider.dart b/frontend/lib/providers/build_provider.dart index 6acfc72..6800bf5 100644 --- a/frontend/lib/providers/build_provider.dart +++ b/frontend/lib/providers/build_provider.dart @@ -15,5 +15,6 @@ class BuildProvider extends BaseProvider { loadFuture(context, {dto}) { // todo search solution to force an exising dto data = API.getBuild(dto!.buildID); + this.dto = dto; } } diff --git a/frontend/lib/providers/builds_provider.dart b/frontend/lib/providers/builds_provider.dart index deeea50..7d7cd49 100644 --- a/frontend/lib/providers/builds_provider.dart +++ b/frontend/lib/providers/builds_provider.dart @@ -16,6 +16,7 @@ class BuildsProvider extends BaseProvider, BuildsDTO> { loadFuture(context, {dto}) { if (dto != null) { data = API.listAllBuilds(pkgID: dto.pkgID, limit: dto.limit); + this.dto = dto; } else { data = API.listAllBuilds(); } diff --git a/frontend/lib/providers/package_provider.dart b/frontend/lib/providers/package_provider.dart index 74e485c..d78892d 100644 --- a/frontend/lib/providers/package_provider.dart +++ b/frontend/lib/providers/package_provider.dart @@ -15,5 +15,6 @@ class PackageProvider extends BaseProvider { loadFuture(context, {dto}) { // todo search solution to force an exising dto data = API.getPackage(dto!.pkgID); + this.dto = dto; } } diff --git a/frontend/lib/providers/packages_provider.dart b/frontend/lib/providers/packages_provider.dart index de9b171..ac54229 100644 --- a/frontend/lib/providers/packages_provider.dart +++ b/frontend/lib/providers/packages_provider.dart @@ -14,5 +14,6 @@ class PackagesProvider extends BaseProvider, PackagesDTO> { @override loadFuture(context, {dto}) { data = API.listPackages(limit: dto?.limit); + this.dto = dto; } } diff --git a/frontend/lib/providers/stats_provider.dart b/frontend/lib/providers/stats_provider.dart index 6565aa5..203ea7d 100644 --- a/frontend/lib/providers/stats_provider.dart +++ b/frontend/lib/providers/stats_provider.dart @@ -7,5 +7,6 @@ class StatsProvider extends BaseProvider { @override loadFuture(context, {dto}) { data = API.listStats(); + this.dto = dto; } }