Skip to content

Commit

Permalink
MDL-76011 lib: Updated the zip writer to retain the modified date.
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Oct 27, 2022
1 parent 046e48c commit 2b2b4e6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion files/classes/local/archive_writer/zip_writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use ZipStream\Option\Archive;
use ZipStream\ZipStream;
use ZipStream\Option\File as FileOptions;
use core_files\archive_writer;
use core_files\local\archive_writer\file_writer_interface as file_writer_interface;
use core_files\local\archive_writer\stream_writer_interface as stream_writer_interface;
Expand Down Expand Up @@ -110,8 +111,12 @@ public function add_file_from_stream(string $name, $stream): void {
}

public function add_file_from_stored_file(string $name, \stored_file $file): void {
$datetime = new \DateTime();
$datetime->setTimestamp($file->get_timemodified());
$fileoptions = new FileOptions();
$fileoptions->setTime($datetime);
$filehandle = $file->get_content_file_handle();
$this->archive->addFileFromStream($this->sanitise_filepath($name), $filehandle);
$this->archive->addFileFromStream($this->sanitise_filepath($name), $filehandle, $fileoptions);
fclose($filehandle);
}

Expand Down

0 comments on commit 2b2b4e6

Please sign in to comment.