Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Apr 25, 2024
1 parent 8950a33 commit 1bcf6ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion web/app/Filament/Resources/BackupResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public static function table(Table $table): Table

Tables\Columns\TextColumn::make('size')
->state(function (Backup $backup) {
return $backup->size ? Number::fileSize($backup->size) : 'N/A';
return $backup->size ? $backup->size : 'N/A';
}),
])
->filters([
Expand Down
15 changes: 14 additions & 1 deletion web/app/Models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Support\Number;
use Illuminate\Support\Str;

class Backup extends Model
Expand Down Expand Up @@ -81,7 +82,7 @@ public function checkBackup()

$backupDoneFile = $this->path.'/backup.done';
if (file_exists($backupDoneFile)) {
$this->size = filesize($this->filepath);
$this->size = Number::fileSize(filesize($this->filepath));
$this->status = 'completed';
$this->completed = true;
$this->completed_at = now();
Expand All @@ -94,6 +95,18 @@ public function checkBackup()

$checkProcess = shell_exec('ps -p ' . $this->process_id . ' | grep ' . $this->process_id);
if (Str::contains($checkProcess, $this->process_id)) {

// Check path size
$pathSize = shell_exec('du -sh ' . $this->path);
$pathSize = trim($pathSize);
$pathSize = explode("\t", $pathSize);

if (isset($pathSize[0])) {
$pathSize = $pathSize[0];
$this->size = $pathSize;
$this->save();
}

return [
'status' => 'processing',
'message' => 'Backup is still processing'
Expand Down

0 comments on commit 1bcf6ca

Please sign in to comment.