Skip to content

Commit 29fcd17

Browse files
committed
Case 27611; Corrected use of remote streams.
1 parent 9097c80 commit 29fcd17

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/Command/SiteDbImportCommand.php

+19-6
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,30 @@ protected function download($filename) {
281281
throw new SiteCommandException($shellProcess->getOutput());
282282
}
283283
}
284-
elseif (file_exists($filename)) {
285-
$saved = file_put_contents($filename, $tmp_folder . basename($filename));
286-
if ($saved !== FALSE) {
284+
else {
285+
// Open a stream in read-only mode
286+
if ($stream = fopen($filename, 'r')) {
287+
// Open the destination file to save the output to.
288+
$output_file = fopen ($tmp_folder . basename($filename), "a");
289+
if ($output_file)
290+
while(!feof($stream)) {
291+
fwrite($output_file, fread($stream, 1024), 1024);
292+
}
293+
fclose($stream);
294+
if ($output_file) {
295+
fclose($output_file);
296+
}
297+
}
298+
else {
287299
throw new SiteCommandException("The DB dump could not be saved to the local destination.");
288300
}
289301
}
290-
else {
291-
throw new SiteCommandException("The DB dump file does not exist.");
292-
}
293302

294303
return $tmp_folder . basename($filename);
295304
}
296305

306+
protected function remoteFileExists($filename) {
307+
308+
}
309+
297310
}

0 commit comments

Comments
 (0)