]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed getLocalFile() condition for x-send-file
authorVincent Petry <pvince81@owncloud.com>
Wed, 20 Nov 2013 13:33:59 +0000 (14:33 +0100)
committerVincent Petry <pvince81@owncloud.com>
Wed, 20 Nov 2013 13:33:59 +0000 (14:33 +0100)
Until now, addSendfileHeader() was called even when no x-send-file
headers were set. Even though the method itself doesn't do anything,
a call to getLocalFile() was done and would trigger a full download
when using external storage.

Additionally, the storage resolution code is wrong and always
returns the local storage of the root filesystem, which caused the code to
be run anyway.

This commit fixes both issues.

lib/private/files.php

index 8b4d5c59aee0cb8595eb3255b10e9348cef373e8..e76dd8644c1cc1d2072c31aaf6d761cb5c3e0fe9 100644 (file)
@@ -131,9 +131,11 @@ class OC_Files {
                                if ($filesize > -1) {
                                        header("Content-Length: ".$filesize);
                                }
-                               list($storage) = \OC\Files\Filesystem::resolvePath($filename);
-                               if ($storage instanceof \OC\Files\Storage\Local) {
-                                       self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
+                               if ($xsendfile) {
+                                       list($storage) = \OC\Files\Filesystem::resolvePath(\OC\Files\Filesystem::getView()->getAbsolutePath($filename));
+                                       if ($storage instanceof \OC\Files\Storage\Local) {
+                                               self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
+                                       }
                                }
                        }
                } elseif ($zip or !\OC\Files\Filesystem::file_exists($filename)) {