From 28df7be3192560b1b3616b98a5a1f057410ebab0 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Thu, 24 Sep 2015 01:08:42 +0300 Subject: [PATCH] Add namespace. Fix broken zip --- lib/private/files.php | 3 ++- lib/private/streamer.php | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/private/files.php b/lib/private/files.php index 638d148adc..21b3cd1d40 100644 --- a/lib/private/files.php +++ b/lib/private/files.php @@ -41,6 +41,7 @@ */ use OC\Lock\NoopLockingProvider; +use OC\Streamer; use OCP\Lock\ILockingProvider; /** @@ -113,7 +114,7 @@ class OC_Files { if ($getType === self::FILE) { $streamer = false; } else { - $streamer = new OC_Streamer(); + $streamer = new Streamer(); } OC_Util::obEnd(); diff --git a/lib/private/streamer.php b/lib/private/streamer.php index aec5fb922e..b530961afd 100644 --- a/lib/private/streamer.php +++ b/lib/private/streamer.php @@ -19,10 +19,12 @@ * */ -use \ZipStreamer\ZipStreamer; +namespace OC; + +use ZipStreamer\ZipStreamer; use DeepDiver1975\TarStreamer\TarStreamer; -class OC_Streamer { +class Streamer { // array of regexp. Matching user agents will get tar instead of zip private $preferTarFor = [ '/macintosh|mac os x/i' ]; @@ -36,7 +38,7 @@ class OC_Streamer { /** @var \OCP\IRequest */ $request = \OC::$server->getRequest(); - if ($request->isUserAgent($this->preferTar)) { + if ($request->isUserAgent($this->preferTarFor)) { $this->streamerInstance = new TarStreamer(); } else { $this->streamerInstance = new ZipStreamer(); @@ -75,7 +77,7 @@ class OC_Streamer { if(\OC\Files\Filesystem::is_file($file)) { $filesize = \OC\Files\Filesystem::filesize($file); $fh = \OC\Files\Filesystem::fopen($file, 'r'); - $this->streamerInstance->addFileFromStream($fh, $internalDir . $filename, $filesize); + $this->addFileFromStream($fh, $internalDir . $filename, $filesize); fclose($fh); }elseif(\OC\Files\Filesystem::is_dir($file)) { $this->addDirRecoursive($file, $internalDir);