diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2019-11-07 11:03:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-07 11:03:18 +0100 |
commit | 9fe4b953e98a067b77ccf10f848b97724ac82c0a (patch) | |
tree | 6bda0741c0ca1537da0722b883ef86b6b56fa01f /lib | |
parent | e693709d5e6f2c3ceeafcb26ae27efad08c55b77 (diff) | |
parent | f9bfd48e12b2e9a50c8b38f991b56f4da194d911 (diff) | |
download | nextcloud-server-9fe4b953e98a067b77ccf10f848b97724ac82c0a.tar.gz nextcloud-server-9fe4b953e98a067b77ccf10f848b97724ac82c0a.zip |
Merge pull request #17822 from nextcloud/fix/noid/tip-download-to-node-api
switch to Files Node API for zip generation
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/legacy/files.php | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/private/legacy/files.php b/lib/private/legacy/files.php index 577392f1edc..140c02e77b6 100644 --- a/lib/private/legacy/files.php +++ b/lib/private/legacy/files.php @@ -177,10 +177,21 @@ class OC_Files { foreach ($files as $file) { $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, $fileTime); + $userFolder = \OC::$server->getRootFolder()->get(\OC\Files\Filesystem::getRoot()); + $file = $userFolder->get($file); + if($file instanceof \OC\Files\Node\File) { + $fh = $file->fopen('r'); + $fileSize = $file->getSize(); + $fileTime = $file->getMTime(); + } else { + // File is not a file? … + \OC::$server->getLogger()->debug( + 'File given, but no Node available. Name {file}', + [ 'app' => 'files', 'file' => $file ] + ); + continue; + } + $streamer->addFileFromStream($fh, $file->getName(), $fileSize, $fileTime); fclose($fh); } elseif (\OC\Files\Filesystem::is_dir($file)) { $streamer->addDirRecursive($file); |