mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
chore: Merge pull request 'feat(digital-ocean): Implement uniqueness check' (#239) from digital-ocean-uniqueness into master
Reviewed-on: https://git.selfprivacy.org/SelfPrivacy/selfprivacy.org.app/pulls/239 Reviewed-by: Inex Code <inex.code@selfprivacy.org>
This commit is contained in:
commit
51f5bb9f31
|
@ -97,6 +97,38 @@ class DigitalOceanServerProvider extends ServerProvider {
|
||||||
final hostname = getHostnameFromDomain(
|
final hostname = getHostnameFromDomain(
|
||||||
installationData.serverDomain.domainName,
|
installationData.serverDomain.domainName,
|
||||||
);
|
);
|
||||||
|
final pastServers = await getServers();
|
||||||
|
for (final pastServer in pastServers.data) {
|
||||||
|
if (pastServer.name == hostname) {
|
||||||
|
return GenericResult(
|
||||||
|
data: CallbackDialogueBranching(
|
||||||
|
choices: [
|
||||||
|
CallbackDialogueChoice(
|
||||||
|
title: 'basis.cancel'.tr(),
|
||||||
|
callback: () async => installationData.errorCallback(),
|
||||||
|
),
|
||||||
|
CallbackDialogueChoice(
|
||||||
|
title: 'modals.yes'.tr(),
|
||||||
|
callback: () async {
|
||||||
|
final deleting = await deleteServer(hostname);
|
||||||
|
if (deleting.success) {
|
||||||
|
await Future.delayed(const Duration(seconds: 20));
|
||||||
|
return launchInstallation(installationData);
|
||||||
|
}
|
||||||
|
|
||||||
|
return deleting;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
description: 'modals.destroy_server'.tr(),
|
||||||
|
title: 'modals.already_exists'.tr(),
|
||||||
|
),
|
||||||
|
success: false,
|
||||||
|
message: 'Droplet "$hostname" already exists.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final serverResult = await _adapter.api().createServer(
|
final serverResult = await _adapter.api().createServer(
|
||||||
dnsApiToken: installationData.dnsApiToken,
|
dnsApiToken: installationData.dnsApiToken,
|
||||||
rootUser: installationData.rootUser,
|
rootUser: installationData.rootUser,
|
||||||
|
@ -144,7 +176,7 @@ class DigitalOceanServerProvider extends ServerProvider {
|
||||||
|
|
||||||
String? ipv4;
|
String? ipv4;
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
while (attempts < 5 && ipv4 == null) {
|
while (attempts < 10 && ipv4 == null) {
|
||||||
await Future.delayed(const Duration(seconds: 20));
|
await Future.delayed(const Duration(seconds: 20));
|
||||||
final servers = await getServers();
|
final servers = await getServers();
|
||||||
for (final server in servers.data) {
|
for (final server in servers.data) {
|
||||||
|
|
Loading…
Reference in a new issue