summaryrefslogtreecommitdiffstats
path: root/lib/private/Streamer.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-11-28 11:36:10 +0100
committerJoas Schilling <coding@schilljs.com>2016-11-28 11:36:10 +0100
commitd2ff6c569e93133026454150f71a7e8afd36b9e5 (patch)
treee778feacdd8e6d97b93b101cc11336675411022b /lib/private/Streamer.php
parentca7b9e54903286c63031739fa31ecbd33084d7b4 (diff)
downloadnextcloud-server-d2ff6c569e93133026454150f71a7e8afd36b9e5.tar.gz
nextcloud-server-d2ff6c569e93133026454150f71a7e8afd36b9e5.zip
Keep the filemtime for files when downloading them in a zip/tar
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Streamer.php')
-rw-r--r--lib/private/Streamer.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/private/Streamer.php b/lib/private/Streamer.php
index 75877ab166a..52eeea422ef 100644
--- a/lib/private/Streamer.php
+++ b/lib/private/Streamer.php
@@ -76,8 +76,9 @@ class Streamer {
$file = $dir . '/' . $filename;
if(\OC\Files\Filesystem::is_file($file)) {
$filesize = \OC\Files\Filesystem::filesize($file);
+ $fileTime = \OC\Files\Filesystem::filemtime($file);
$fh = \OC\Files\Filesystem::fopen($file, 'r');
- $this->addFileFromStream($fh, $internalDir . $filename, $filesize);
+ $this->addFileFromStream($fh, $internalDir . $filename, $filesize, $fileTime);
fclose($fh);
}elseif(\OC\Files\Filesystem::is_dir($file)) {
$this->addDirRecursive($file, $internalDir);
@@ -93,11 +94,18 @@ class Streamer {
* @param int $size Filesize
* @return bool $success
*/
- public function addFileFromStream($stream, $internalName, $size){
+ public function addFileFromStream($stream, $internalName, $size, $time) {
+ $options = [];
+ if ($time) {
+ $options = [
+ 'timestamp' => $time
+ ];
+ }
+
if ($this->streamerInstance instanceof ZipStreamer) {
- return $this->streamerInstance->addFileFromStream($stream, $internalName);
+ return $this->streamerInstance->addFileFromStream($stream, $internalName, $options);
} else {
- return $this->streamerInstance->addFileFromStream($stream, $internalName, $size);
+ return $this->streamerInstance->addFileFromStream($stream, $internalName, $size, $options);
}
}