Skip to content
Snippets Groups Projects
Unverified Commit 76b86646 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3163663 by mpp, chrisolof, alexpott, quietone: Too many open files...

Issue #3163663 by mpp, chrisolof, alexpott, quietone: Too many open files issue with migrating multiple files using "download" process plugin
parent 5c78c189
No related branches found
No related tags found
No related merge requests found
......@@ -155,6 +155,10 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
throw new MigrateException("{$e->getMessage()} ($source)");
}
if (is_resource($destination_stream)) {
fclose($destination_stream);
}
return $final_destination;
}
......
......@@ -34,7 +34,7 @@ protected function setUp(): void {
* Tests a download that overwrites an existing local file.
*/
public function testOverwritingDownload() {
// Create a pre-existing file at the destination, to test overwrite behavior.
// Create a pre-existing file at the destination.
$destination_uri = $this->createUri('existing_file.txt');
// Test destructive download.
......@@ -47,7 +47,7 @@ public function testOverwritingDownload() {
* Tests a download that renames the downloaded file if there's a collision.
*/
public function testNonDestructiveDownload() {
// Create a pre-existing file at the destination, to test overwrite behavior.
// Create a pre-existing file at the destination.
$destination_uri = $this->createUri('another_existing_file.txt');
// Test non-destructive download.
......@@ -60,7 +60,7 @@ public function testNonDestructiveDownload() {
* Tests that an exception is thrown if the destination URI is not writable.
*/
public function testWriteProtectedDestination() {
// Create a pre-existing file at the destination, to test overwrite behavior.
// Create a pre-existing file at the destination.
$destination_uri = $this->createUri('not-writable.txt');
// Make the destination non-writable.
......@@ -115,7 +115,13 @@ protected function doTransform($destination_uri, $configuration = []) {
'http://drupal.org/favicon.ico',
$destination_uri,
];
return $plugin->transform($value, $executable, $row, 'foo');
// Assert that number of stream resources in use is the same before and
// after the download.
$initial_count = count(get_resources('stream'));
$return = $plugin->transform($value, $executable, $row, 'foo');
$this->assertCount($initial_count, get_resources('stream'));
return $return;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment