Skip to content

Commit

Permalink
MDL-60001 core_files: Use local file for gzopen
Browse files Browse the repository at this point in the history
The gzopen method does not appear to support
file streams.
  • Loading branch information
polothy committed Aug 31, 2017
1 parent 9eb3c17 commit 879827d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/filestorage/file_system.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,12 @@ abstract public function add_file_from_string($content);
* @return resource file handle
*/
public function get_content_file_handle(stored_file $file, $type = stored_file::FILE_HANDLE_FOPEN) {
$path = $this->get_remote_path_from_storedfile($file);
if ($type === stored_file::FILE_HANDLE_GZOPEN) {
// Local file required for gzopen.
$path = $this->get_local_path_from_storedfile($file, true);
} else {
$path = $this->get_remote_path_from_storedfile($file);
}

return self::get_file_handle_for_path($path, $type);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/filestorage/tests/file_system_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,8 @@ public function test_get_content_file_handle_gz() {
$filecontent = 'example content';
$file = $this->get_stored_file($filecontent);

$fs = $this->get_testable_mock(['get_remote_path_from_storedfile']);
$fs->method('get_remote_path_from_storedfile')
$fs = $this->get_testable_mock(['get_local_path_from_storedfile']);
$fs->method('get_local_path_from_storedfile')
->willReturn(__DIR__ . "/fixtures/test.tgz");

// Note: We are unable to determine the mode in which the $fh was opened.
Expand Down

0 comments on commit 879827d

Please sign in to comment.