Merge pull request #17841 from nextcloud/backport/17822/stable16

[stable16] switch to Files Node API for zip generation
This commit is contained in:
Roeland Jago Douma 2019-11-07 12:59:33 +01:00 committed by GitHub
commit d171d1aff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -177,10 +177,21 @@ class OC_Files {
foreach ($files as $file) { foreach ($files as $file) {
$file = $dir . '/' . $file; $file = $dir . '/' . $file;
if (\OC\Files\Filesystem::is_file($file)) { if (\OC\Files\Filesystem::is_file($file)) {
$fileSize = \OC\Files\Filesystem::filesize($file); $userFolder = \OC::$server->getRootFolder()->get(\OC\Files\Filesystem::getRoot());
$fileTime = \OC\Files\Filesystem::filemtime($file); $file = $userFolder->get($file);
$fh = \OC\Files\Filesystem::fopen($file, 'r'); if($file instanceof \OC\Files\Node\File) {
$streamer->addFileFromStream($fh, basename($file), $fileSize, $fileTime); $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); fclose($fh);
} elseif (\OC\Files\Filesystem::is_dir($file)) { } elseif (\OC\Files\Filesystem::is_dir($file)) {
$streamer->addDirRecursive($file); $streamer->addDirRecursive($file);