mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-74123 h5p: delete any existing files when downloading new files
This commit is contained in:
parent
bb864ee2e1
commit
a1fa5e7178
1 changed files with 15 additions and 1 deletions
|
@ -238,8 +238,22 @@ class core extends H5PCore {
|
||||||
|
|
||||||
$factory = new factory();
|
$factory = new factory();
|
||||||
|
|
||||||
// Download the latest content type from the H5P official repository.
|
|
||||||
$fs = get_file_storage();
|
$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(
|
$file = $fs->create_file_from_url(
|
||||||
(object) [
|
(object) [
|
||||||
'component' => 'core_h5p',
|
'component' => 'core_h5p',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue