Skip to content

Commit

Permalink
Merge branch 'MDL-74123_h5p_duplicate_file' of https://github.com/dav…
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Mar 10, 2022
2 parents a745a7d + 4202104 commit ae935e8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion h5p/classes/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,22 @@ public function fetch_content_type(array $library): ?int {

$factory = new factory();

// Download the latest content type from the H5P official repository.
$fs = get_file_storage();

// Delete any existing file, if it was not deleted during a previous download.
$existing = $fs->get_file(
(\context_system::instance())->id,
'core_h5p',
'library_sources',
0,
'/',
$library['machineName']
);
if ($existing) {
$existing->delete();
}

// Download the latest content type from the H5P official repository.
$file = $fs->create_file_from_url(
(object) [
'component' => 'core_h5p',
Expand Down

0 comments on commit ae935e8

Please sign in to comment.