Skip to content

Commit

Permalink
chore: Refactor SqliteBackupCommand to improve backup directory creat…
Browse files Browse the repository at this point in the history
…ion and file path handling
  • Loading branch information
arnebr committed Jun 16, 2024
1 parent dff41c3 commit 00ce301
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Commands/SqliteBackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ public function handle(): int
$backupPath = database_path('backups');

// Create the backup directory if it doesn't exist
if (! File::ensureDirectoryExists($backupPath)) {
if (File::isDirectory($backupPath)) {
$this->info('Backup directory created at: '.$backupPath);
File::makeDirectory($backupPath);
}

try {
// Create a backup of the SQLite database
File::copy($database, database_path('backups/'.$filename));
$file_path = database_path('backups/'.$filename);
File::copy($database, $file_path);

$this->info('SQLite backup created successfully at: '.database_path('backups/'.$filename));
$this->info('SQLite backup created successfully at: '.$file_path);

return Command::SUCCESS;
} catch (\Exception $e) {
Expand Down

0 comments on commit 00ce301

Please sign in to comment.