Skip to content

Commit

Permalink
Update Backup.php
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Apr 25, 2024
1 parent 1bcf6ca commit eef776d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions web/app/Models/Backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function checkBackup()

$backupDoneFile = $this->path.'/backup.done';
if (file_exists($backupDoneFile)) {
$this->size = Number::fileSize(filesize($this->filepath));
$this->size = $this->checkPathSize($this->path);
$this->status = 'completed';
$this->completed = true;
$this->completed_at = now();
Expand All @@ -96,16 +96,8 @@ 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();
}
$this->size = $this->checkPathSize($this->path);
$this->save();

return [
'status' => 'processing',
Expand Down Expand Up @@ -205,4 +197,19 @@ public function startBackup()
}

}

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

if (isset($pathSize[0])) {
$pathSize = $pathSize[0];
return $pathSize;
}

return 0;
}
}

0 comments on commit eef776d

Please sign in to comment.