]> source.dussan.org Git - nextcloud-server.git/commitdiff
Keep the filemtime for files when downloading them in a zip/tar
authorJoas Schilling <coding@schilljs.com>
Mon, 28 Nov 2016 10:36:10 +0000 (11:36 +0100)
committerJoas Schilling <coding@schilljs.com>
Mon, 28 Nov 2016 10:36:10 +0000 (11:36 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Streamer.php
lib/private/legacy/files.php

index 75877ab166a9ccc9e57f872c8fc52c366687a4f0..52eeea422ef4ac1de19e4ea7cc0f34ab671ff2e2 100644 (file)
@@ -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);
                }
        }
 
index 064fa9e1d7abdd164a07f662a5f1100f04d40925..b6c6857a1bfaae70cb9cfefc5c34b90faa2aff97 100644 (file)
@@ -153,8 +153,9 @@ class OC_Files {
                                        $file = $dir . '/' . $file;
                                        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');
-                                               $streamer->addFileFromStream($fh, basename($file), $fileSize);
+                                               $streamer->addFileFromStream($fh, basename($file), $fileSize, $fileTime);
                                                fclose($fh);
                                        } elseif (\OC\Files\Filesystem::is_dir($file)) {
                                                $streamer->addDirRecursive($file);