mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
Merge branch 'MDL-41839-master' of git://github.com/sammarshallou/moodle
This commit is contained in:
commit
14976b3568
@ -446,6 +446,22 @@ class core_files_zip_packer_testcase extends advanced_testcase implements file_p
|
||||
array(file_progress::INDETERMINATE, file_progress::INDETERMINATE),
|
||||
$this->progress[0]);
|
||||
|
||||
// Archive to pathname using entire folder and subfolder instead of file list.
|
||||
unlink($archive);
|
||||
$folder = make_temp_directory('zip_packer_progress');
|
||||
file_put_contents($folder . '/test1.txt', 'hello');
|
||||
$subfolder = $folder . '/sub';
|
||||
check_dir_exists($subfolder);
|
||||
file_put_contents($subfolder . '/test2.txt', 'world');
|
||||
file_put_contents($subfolder . '/test3.txt', 'and');
|
||||
file_put_contents($subfolder . '/test4.txt', 'other');
|
||||
file_put_contents($subfolder . '/test5.txt', 'worlds');
|
||||
$this->progress = array();
|
||||
$result = $packer->archive_to_pathname(array('' => $folder), $archive, true, $this);
|
||||
$this->assertTrue($result);
|
||||
// Should send progress at least once per file.
|
||||
$this->assertTrue(count($this->progress) >= 5);
|
||||
|
||||
// Archive to storage.
|
||||
$this->progress = array();
|
||||
$archivefile = $packer->archive_to_storage($this->files, $context->id,
|
||||
|
@ -122,7 +122,7 @@ class zip_packer extends file_packer {
|
||||
}
|
||||
|
||||
} else if (is_string($file)) {
|
||||
if (!$this->archive_pathname($ziparch, $archivepath, $file)) {
|
||||
if (!$this->archive_pathname($ziparch, $archivepath, $file, $progress)) {
|
||||
debugging("Can not zip '$archivepath' file", DEBUG_DEVELOPER);
|
||||
if (!$ignoreinvalidfiles) {
|
||||
$abort = true;
|
||||
@ -141,7 +141,7 @@ class zip_packer extends file_packer {
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!$this->archive_stored($ziparch, $archivepath, $file)) {
|
||||
if (!$this->archive_stored($ziparch, $archivepath, $file, $progress)) {
|
||||
debugging("Can not zip '$archivepath' file", DEBUG_DEVELOPER);
|
||||
if (!$ignoreinvalidfiles) {
|
||||
$abort = true;
|
||||
@ -242,7 +242,7 @@ class zip_packer extends file_packer {
|
||||
continue;
|
||||
}
|
||||
$newpath = $archivepath.'/'.$file->getFilename();
|
||||
$this->archive_pathname($ziparch, $newpath, $file->getPathname());
|
||||
$this->archive_pathname($ziparch, $newpath, $file->getPathname(), $progress);
|
||||
}
|
||||
unset($files); // Release file handles.
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user