nextcloud hotfix

This commit is contained in:
STAM 2020-03-24 21:21:13 +03:00
parent 0fd65125d9
commit bc306dfa62
3 changed files with 43 additions and 20 deletions

View File

@ -53,6 +53,7 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio
mc \ mc \
mercurial \ mercurial \
nano \ nano \
nload \
nmap \ nmap \
openssl \ openssl \
perl \ perl \

View File

@ -11,8 +11,9 @@ RUN cp -fv /tmp/php-smbclient-latest/etc/php/7.3/mods-available/smbclient.ini /u
RUN apt update -y && apt install -y --allow-unauthenticated sudo apt-transport-https wget htop mc nano smbclient libsmbclient RUN apt update -y && apt install -y --allow-unauthenticated sudo apt-transport-https wget htop mc nano smbclient libsmbclient
#thank u, mac users. rolling back normal ZipStreammer #thank u, mac users. rolling back normal ZipStreammer
RUN rm -frv /var/www/html/lib/private/Streamer.php RUN rm -frv /usr/src/nextcloud/lib/private/Streamer.php
ADD Streamer.php /var/www/html/lib/private/ ADD Streamer.php /usr/src/nextcloud/lib/private/
RUN chown nobody:nogroup /usr/src/nextcloud/lib/private/Streamer.php
#smb fix #smb fix
RUN rm -frv /etc/samba/smb.conf /usr/share/samba/smb.conf RUN rm -frv /etc/samba/smb.conf /usr/share/samba/smb.conf

View File

@ -2,13 +2,15 @@
/** /**
* *
* *
* FIXED ZipStreammer to 64bit. https://github.com/nextcloud/server/pull/15367 * FIXED ZipStreammer to 64bit. 1) https://github.com/nextcloud/server/pull/15367
* * 2) https://github.com/artonge/server/commit/435022515de1983f0fe3d3116acb71a0ed439693
*
* *
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Daniel Calviño Sánchez <danxuliu@gmail.com>
* @author Joas Schilling <coding@schilljs.com> * @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu> * @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Victor Dubiniuk <dubiniuk@owncloud.com> * @author Victor Dubiniuk <dubiniuk@owncloud.com>
* *
@ -24,12 +26,18 @@
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License, version 3, * You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
namespace OC; namespace OC;
use OC\Files\Filesystem;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\InvalidPathException;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\IRequest; use OCP\IRequest;
use ownCloud\TarStreamer\TarStreamer; use ownCloud\TarStreamer\TarStreamer;
use ZipStreamer\ZipStreamer; use ZipStreamer\ZipStreamer;
@ -49,7 +57,7 @@ class Streamer {
* @param int $numberOfFiles The number of files (and directories) that will * @param int $numberOfFiles The number of files (and directories) that will
* be included in the streamed file * be included in the streamed file
*/ */
public function __construct(IRequest $request, int $size, int $numberOfFiles){ public function __construct(IRequest $request, $size, int $numberOfFiles){
/** /**
* zip32 constraints for a basic (without compression, volumes nor * zip32 constraints for a basic (without compression, volumes nor
@ -94,10 +102,12 @@ class Streamer {
/** /**
* Stream directory recursively * Stream directory recursively
* @param string $dir *
* @param string $internalDir * @throws NotFoundException
* @throws NotPermittedException
* @throws InvalidPathException
*/ */
public function addDirRecursive($dir, $internalDir='') { public function addDirRecursive(string $dir, string $internalDir = ''): void {
$dirname = basename($dir); $dirname = basename($dir);
$rootDir = $internalDir . $dirname; $rootDir = $internalDir . $dirname;
if (!empty($rootDir)) { if (!empty($rootDir)) {
@ -107,18 +117,29 @@ class Streamer {
// prevent absolute dirs // prevent absolute dirs
$internalDir = ltrim($internalDir, '/'); $internalDir = ltrim($internalDir, '/');
$files= \OC\Files\Filesystem::getDirectoryContent($dir); $userFolder = \OC::$server->getRootFolder()->get(Filesystem::getRoot());
/** @var Folder $dirNode */
$dirNode = $userFolder->get($dir);
$files = $dirNode->getDirectoryListing();
foreach($files as $file) { foreach($files as $file) {
$filename = $file['name']; if($file instanceof File) {
$file = $dir . '/' . $filename; try {
if(\OC\Files\Filesystem::is_file($file)) { $fh = $file->fopen('r');
$filesize = \OC\Files\Filesystem::filesize($file); } catch (NotPermittedException $e) {
$fileTime = \OC\Files\Filesystem::filemtime($file); continue;
$fh = \OC\Files\Filesystem::fopen($file, 'r'); }
$this->addFileFromStream($fh, $internalDir . $filename, $filesize, $fileTime); $this->addFileFromStream(
$fh,
$internalDir . $file->getName(),
$file->getSize(),
$file->getMTime()
);
fclose($fh); fclose($fh);
}elseif(\OC\Files\Filesystem::is_dir($file)) { } elseif ($file instanceof Folder) {
$this->addDirRecursive($file, $internalDir); if($file->isReadable()) {
$this->addDirRecursive($dir . '/' . $file->getName(), $internalDir);
}
} }
} }
} }