Skip to content

Commit 46c2c38

Browse files
committed
Catch transfer failure
1 parent cb7badd commit 46c2c38

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

src/Migration/Sources/CSV.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ protected function exportGroupFunctions(int $batchSize, array $resources): void
305305
/**
306306
* @param callable(resource $stream): void $callback
307307
* @return void
308+
* @throws \Exception
308309
*/
309310
private function withCsvStream(callable $callback): void
310311
{
@@ -313,11 +314,19 @@ private function withCsvStream(callable $callback): void
313314
}
314315

315316
if ($this->device->getType() !== Storage::DEVICE_LOCAL) {
316-
$this->device->transfer(
317-
$this->filePath,
318-
$this->filePath,
319-
new Device\Local('/'),
320-
);
317+
try {
318+
$success = $this->device->transfer(
319+
$this->filePath,
320+
$this->filePath,
321+
new Device\Local('/'),
322+
);
323+
} catch (\Exception) {
324+
$success = false;
325+
}
326+
327+
if (!$success) {
328+
throw new \Exception('Failed to transfer CSV file from device to local storage.');
329+
}
321330
}
322331

323332
$stream = \fopen($this->filePath, 'r');

0 commit comments

Comments
 (0)