1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-24 01:44:27 +02:00

MDL-61253 repository: Add referenced files to archives

This commit is contained in:
Andrew Nicols 2018-01-23 09:48:05 +08:00
parent f68150ad05
commit 51d31432c8

@ -537,6 +537,18 @@ class stored_file {
* @return bool success
*/
public function archive_file(file_archive $filearch, $archivepath) {
if ($this->repository) {
$this->sync_external_file();
if ($this->compare_to_string('')) {
// This file is not stored locally - attempt to retrieve it from the repository.
// This may happen if the repository deliberately does not fetch files, or if there is a failure with the sync.
$fileinfo = $this->repository->get_file($this->get_reference());
if (isset($fileinfo['path'])) {
return $filearch->add_file_from_pathname($archivepath, $fileinfo['path']);
}
}
}
return $this->filesystem->add_storedfile_to_archive($this, $filearch, $archivepath);
}