This commit is contained in:
Saeed Vaziry
2024-03-24 09:56:34 +01:00
committed by GitHub
parent 884f18db63
commit 4d051330d6
1055 changed files with 14493 additions and 20278 deletions

View File

@ -27,11 +27,18 @@ public function create(User $user, array $input): void
$storageProvider->credentials = $storageProvider->provider()->credentialData($input);
if (! $storageProvider->provider()->connect()) {
try {
if (! $storageProvider->provider()->connect()) {
throw ValidationException::withMessages([
'provider' => __("Couldn't connect to the provider"),
]);
}
} catch (\Throwable $e) {
throw ValidationException::withMessages([
'provider' => __("Couldn't connect to the provider"),
'provider' => $e->getMessage(),
]);
}
$storageProvider->save();
}

View File

@ -0,0 +1,21 @@
<?php
namespace App\Actions\StorageProvider;
use App\Models\StorageProvider;
use Exception;
class DeleteStorageProvider
{
/**
* @throws Exception
*/
public function delete(StorageProvider $storageProvider): void
{
if ($storageProvider->backups()->exists()) {
throw new Exception('This storage provider is being used by a backup.');
}
$storageProvider->delete();
}
}