Restore: go on after a partial write; created tables stay once the database is committed

This commit is contained in:
2026-11-06 18:27:00 +01:00
parent dd2e1af997
commit ee406c481e
3 changed files with 52 additions and 17 deletions
+7 -2
View File
@@ -451,12 +451,17 @@ final class Repository {
/**
* Write all of $data, or stop: a short write leaves a file that looks damaged only by its size.
* A write may take only part of the data and still be fine; one that takes nothing is not.
*
* @param resource $out
*/
public static function writeAll($out, string $data, string $path): void {
if (@fwrite($out, $data) !== strlen($data)) {
throw new RestoreTargetException('Cannot write ' . $path . ' to the restore directory (disk full?)');
while ($data !== '') {
$written = @fwrite($out, $data);
if ($written === false || $written === 0) {
throw new RestoreTargetException('Cannot write ' . $path . ' to the restore directory (disk full?)');
}
$data = substr($data, $written);
}
}