fix backup issues

This commit is contained in:
Bozhidar 2024-05-09 16:58:36 +03:00
parent 5b20b10b90
commit 97ee0da261
3 changed files with 13 additions and 19 deletions

View file

@ -118,9 +118,9 @@ class BackupResource extends Resource
->label('View Log')
->icon('heroicon-o-document')
->hidden(function (Backup $backup) {
$hide = false;
if ($backup->status === BackupStatus::Completed) {
$hide = true;
$hide = true;
if ($backup->status === BackupStatus::Processing || $backup->status === BackupStatus::Failed) {
$hide = false;
}
return $hide;
})

View file

@ -91,16 +91,6 @@ class ManageHostingSubscriptionBackups extends ManageRelatedRecords
public function table(Table $table): Table
{
$findHostingSubscription = HostingSubscriptionBackup::where('hosting_subscription_id', $this->record->id)
->where('status', 'processing')
->get();
if ($findHostingSubscription->count() > 0) {
foreach ($findHostingSubscription as $backup) {
$backup->checkBackup();
}
}
return $table
->recordTitleAttribute('file_name')
->columns([
@ -145,13 +135,14 @@ class ManageHostingSubscriptionBackups extends ManageRelatedRecords
return redirect($tempUrl);
}),
Tables\Actions\Action::make('viewLog')
->label('View Log')
->icon('heroicon-o-document')
->hidden(function (HostingSubscriptionBackup $backup) {
$hide = false;
if ($backup->status === BackupStatus::Completed) {
$hide = true;
$hide = true;
if ($backup->status === BackupStatus::Processing || $backup->status === BackupStatus::Failed) {
$hide = false;
}
return $hide;
})

View file

@ -126,6 +126,7 @@ class HostingSubscriptionBackup extends Model
if (Str::contains($checkProcess, $this->process_id)) {
$this->size = 0;
$this->backup_log = "Backup is started with process id: $this->process_id";
$this->save();
return [
@ -134,6 +135,7 @@ class HostingSubscriptionBackup extends Model
];
} else {
$this->status = 'failed';
$this->backup_log = "Backup failed. Process not found";
$this->save();
return [
'status' => 'failed',
@ -155,12 +157,13 @@ class HostingSubscriptionBackup extends Model
];
}
if ($this->status == BackupStatus::Processing) {
if ($this->status !== BackupStatus::Pending) {
return [
'status' => 'processing',
'message' => 'Backup is already processing'
'status' => 'failed',
'message' => 'Backup already started'
];
}
$findMainDomain = Domain::where('hosting_subscription_id', $findHostingSubscription->id)
->where('is_main', 1)
->first();