Add namespace. Fix broken zip
This commit is contained in:
parent
74d879d039
commit
28df7be319
|
@ -41,6 +41,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OC\Lock\NoopLockingProvider;
|
use OC\Lock\NoopLockingProvider;
|
||||||
|
use OC\Streamer;
|
||||||
use OCP\Lock\ILockingProvider;
|
use OCP\Lock\ILockingProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -113,7 +114,7 @@ class OC_Files {
|
||||||
if ($getType === self::FILE) {
|
if ($getType === self::FILE) {
|
||||||
$streamer = false;
|
$streamer = false;
|
||||||
} else {
|
} else {
|
||||||
$streamer = new OC_Streamer();
|
$streamer = new Streamer();
|
||||||
}
|
}
|
||||||
OC_Util::obEnd();
|
OC_Util::obEnd();
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \ZipStreamer\ZipStreamer;
|
namespace OC;
|
||||||
|
|
||||||
|
use ZipStreamer\ZipStreamer;
|
||||||
use DeepDiver1975\TarStreamer\TarStreamer;
|
use DeepDiver1975\TarStreamer\TarStreamer;
|
||||||
|
|
||||||
class OC_Streamer {
|
class Streamer {
|
||||||
// array of regexp. Matching user agents will get tar instead of zip
|
// array of regexp. Matching user agents will get tar instead of zip
|
||||||
private $preferTarFor = [ '/macintosh|mac os x/i' ];
|
private $preferTarFor = [ '/macintosh|mac os x/i' ];
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ class OC_Streamer {
|
||||||
/** @var \OCP\IRequest */
|
/** @var \OCP\IRequest */
|
||||||
$request = \OC::$server->getRequest();
|
$request = \OC::$server->getRequest();
|
||||||
|
|
||||||
if ($request->isUserAgent($this->preferTar)) {
|
if ($request->isUserAgent($this->preferTarFor)) {
|
||||||
$this->streamerInstance = new TarStreamer();
|
$this->streamerInstance = new TarStreamer();
|
||||||
} else {
|
} else {
|
||||||
$this->streamerInstance = new ZipStreamer();
|
$this->streamerInstance = new ZipStreamer();
|
||||||
|
@ -75,7 +77,7 @@ class OC_Streamer {
|
||||||
if(\OC\Files\Filesystem::is_file($file)) {
|
if(\OC\Files\Filesystem::is_file($file)) {
|
||||||
$filesize = \OC\Files\Filesystem::filesize($file);
|
$filesize = \OC\Files\Filesystem::filesize($file);
|
||||||
$fh = \OC\Files\Filesystem::fopen($file, 'r');
|
$fh = \OC\Files\Filesystem::fopen($file, 'r');
|
||||||
$this->streamerInstance->addFileFromStream($fh, $internalDir . $filename, $filesize);
|
$this->addFileFromStream($fh, $internalDir . $filename, $filesize);
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
}elseif(\OC\Files\Filesystem::is_dir($file)) {
|
}elseif(\OC\Files\Filesystem::is_dir($file)) {
|
||||||
$this->addDirRecoursive($file, $internalDir);
|
$this->addDirRecoursive($file, $internalDir);
|
||||||
|
|
Loading…
Reference in New Issue