Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Ifsnop/Mysqldump/Mysqldump.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ public function restore($path)
throw new Exception("Failed reading file {$path}. Check access permissions.");
}

$gzfile = false;
$line = trim(fgets($handle));
# .gz files start with 0x1F 0x8B byte sequence
if(preg_match('/^\x1F\x8B/', $line)) {
fclose($handle);
$handle = gzopen($path , 'rb');
$gzfile = true;
} else {
rewind($handle);
}

if(!$this->dbHandler){
$this->connect();
}
Expand All @@ -314,7 +325,11 @@ public function restore($path)
}
}

fclose($handle);
if($gzfile) {
gzclose($handle);
} else {
fclose($handle);
}
}

/**
Expand Down