From acf2001c120211447e4fee0464c5ccc4cf7fca47 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Tue, 30 Jul 2024 19:15:27 +0300 Subject: [PATCH] fix: Server installation fixes --- ...ver_provider_to_exsisting_server_form_cubit.dart | 1 - .../server_installation_repository.dart | 3 +-- .../providers/server_providers/digital_ocean.dart | 13 ++++++++----- lib/logic/providers/server_providers/hetzner.dart | 5 ++++- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/logic/cubit/forms/setup/initializing/add_server_provider_to_exsisting_server_form_cubit.dart b/lib/logic/cubit/forms/setup/initializing/add_server_provider_to_exsisting_server_form_cubit.dart index 27358807..ec907641 100644 --- a/lib/logic/cubit/forms/setup/initializing/add_server_provider_to_exsisting_server_form_cubit.dart +++ b/lib/logic/cubit/forms/setup/initializing/add_server_provider_to_exsisting_server_form_cubit.dart @@ -21,7 +21,6 @@ class AddServerProviderToExistingServerFormCubit extends FormCubit { @override FutureOr onSubmit() async { - // serverInstallationCubit.setServerProviderKey(apiKey.state.value); setServerProviderKey(apiKey.state.value); } diff --git a/lib/logic/cubit/server_installation/server_installation_repository.dart b/lib/logic/cubit/server_installation/server_installation_repository.dart index 3bb52ea5..cd586f7a 100644 --- a/lib/logic/cubit/server_installation/server_installation_repository.dart +++ b/lib/logic/cubit/server_installation/server_installation_repository.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:io'; -import 'package:easy_localization/easy_localization.dart'; import 'package:hive/hive.dart'; import 'package:pub_semver/pub_semver.dart'; import 'package:selfprivacy/config/get_it_config.dart'; @@ -264,7 +263,7 @@ class ServerInstallationRepository { if (result.success && result.data != null) { server.copyWith(startTime: result.data); } else { - getIt().showSnackBar('jobs.reboot_failed'.tr()); + // getIt().showSnackBar('jobs.reboot_failed'.tr()); } return server; diff --git a/lib/logic/providers/server_providers/digital_ocean.dart b/lib/logic/providers/server_providers/digital_ocean.dart index 356b8365..b199bc3c 100644 --- a/lib/logic/providers/server_providers/digital_ocean.dart +++ b/lib/logic/providers/server_providers/digital_ocean.dart @@ -409,7 +409,9 @@ class DigitalOceanServerProvider extends ServerProvider { final String location, ) async { final bool apiInitialized = _adapter.api().isWithToken; - if (!apiInitialized) { + final String token = _adapter._api.token; + + if (!apiInitialized || token.isEmpty) { return GenericResult( success: true, data: false, @@ -417,10 +419,11 @@ class DigitalOceanServerProvider extends ServerProvider { ); } - // _adapter = ApiAdapter( - // isWithToken: true, - // region: location, - // ); + _adapter = ApiAdapter( + isWithToken: true, + region: location, + token: token, + ); return success; } diff --git a/lib/logic/providers/server_providers/hetzner.dart b/lib/logic/providers/server_providers/hetzner.dart index 10f2c8e0..3c5a7232 100644 --- a/lib/logic/providers/server_providers/hetzner.dart +++ b/lib/logic/providers/server_providers/hetzner.dart @@ -428,7 +428,8 @@ class HetznerServerProvider extends ServerProvider { final String location, ) async { final bool apiInitialized = _adapter.api().isWithToken; - if (!apiInitialized) { + final String token = _adapter._api.token; + if (!apiInitialized || token.isEmpty) { return GenericResult( success: true, data: false, @@ -439,7 +440,9 @@ class HetznerServerProvider extends ServerProvider { _adapter = ApiAdapter( isWithToken: true, region: location, + token: token, ); + return success; }