diff options
Diffstat (limited to 'lib/private')
112 files changed, 580 insertions, 279 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php index 26db0c78df2..7b1d5d29f2e 100644 --- a/lib/private/activitymanager.php +++ b/lib/private/activitymanager.php @@ -3,7 +3,6 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/api.php b/lib/private/api.php index dd50162f03e..8e483b7efe9 100644 --- a/lib/private/api.php +++ b/lib/private/api.php @@ -3,6 +3,7 @@ * @author Bart Visscher <bartv@thisnet.nl> * @author Bernhard Posselt <dev@bernhard-posselt.com> * @author Björn Schießle <schiessle@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> diff --git a/lib/private/app.php b/lib/private/app.php index 4814561baec..1a32fcfcf77 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -312,8 +312,8 @@ class OC_App { \OC::$server->getConfig(), \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($app); - $download= $ocsClient->getApplicationDownload($app); + $appData = $ocsClient->getApplication($app, \OC_Util::getVersion()); + $download= $ocsClient->getApplicationDownload($app, \OC_Util::getVersion()); if(isset($download['downloadlink']) and $download['downloadlink']!='') { // Replace spaces in download link without encoding entire URL $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); @@ -918,7 +918,7 @@ class OC_App { if (is_null($category)) { - $categoryNames = $ocsClient->getCategories(); + $categoryNames = $ocsClient->getCategories(\OC_Util::getVersion()); if (is_array($categoryNames)) { // Check that categories of apps were retrieved correctly if (!$categories = array_keys($categoryNames)) { @@ -930,7 +930,7 @@ class OC_App { } $page = 0; - $remoteApps = $ocsClient->getApplications($categories, $page, $filter); + $remoteApps = $ocsClient->getApplications($categories, $page, $filter, \OC_Util::getVersion()); $apps = []; $i = 0; $l = \OC::$server->getL10N('core'); @@ -1088,7 +1088,7 @@ class OC_App { $config, \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($app); + $appData = $ocsClient->getApplication($app, \OC_Util::getVersion()); // check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string if (!is_numeric($app)) { @@ -1228,17 +1228,18 @@ class OC_App { // manages line breaks itself // first of all we split on empty lines - $paragraphs = preg_split("!\n[[:space:]]*\n!m", $data['description']); + $paragraphs = preg_split("!\n[[:space:]]*\n!mu", $data['description']); $result = []; foreach ($paragraphs as $value) { // replace multiple whitespace (tabs, space, newlines) inside a paragraph // with a single space - also trims whitespace - $result[] = trim(preg_replace('![[:space:]]+!m', ' ', $value)); + $result[] = trim(preg_replace('![[:space:]]+!mu', ' ', $value)); } // join the single paragraphs with a empty line in between $data['description'] = implode("\n\n", $result); + } return $data; diff --git a/lib/private/app/appmanager.php b/lib/private/app/appmanager.php index c9d4a777c4a..7a61cd53c59 100644 --- a/lib/private/app/appmanager.php +++ b/lib/private/app/appmanager.php @@ -1,5 +1,7 @@ <?php /** + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * diff --git a/lib/private/app/codechecker.php b/lib/private/app/codechecker.php index 8c2f3405fb9..326bf8cd888 100644 --- a/lib/private/app/codechecker.php +++ b/lib/private/app/codechecker.php @@ -1,5 +1,6 @@ <?php /** + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * diff --git a/lib/private/app/platformrepository.php b/lib/private/app/platformrepository.php index bebd93006c9..fa71bd7d91a 100644 --- a/lib/private/app/platformrepository.php +++ b/lib/private/app/platformrepository.php @@ -1,6 +1,5 @@ <?php /** - * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index 37532616e1e..b88df10dddd 100644 --- a/lib/private/appconfig.php +++ b/lib/private/appconfig.php @@ -3,6 +3,7 @@ * @author Arthur Schiwon <blizzz@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> * @author Jakob Sack <mail@jakobsack.de> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> diff --git a/lib/private/appframework/app.php b/lib/private/appframework/app.php index f6c1e31cddd..0188d221be1 100644 --- a/lib/private/appframework/app.php +++ b/lib/private/appframework/app.php @@ -1,5 +1,6 @@ <?php /** + * @author Andreas Fischer <bantu@owncloud.com> * @author Bernhard Posselt <dev@bernhard-posselt.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php index 2455209cdf3..7d6a49202c6 100644 --- a/lib/private/appframework/http/request.php +++ b/lib/private/appframework/http/request.php @@ -2,6 +2,7 @@ /** * @author Bart Visscher <bartv@thisnet.nl> * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> diff --git a/lib/private/appframework/utility/controllermethodreflector.php b/lib/private/appframework/utility/controllermethodreflector.php index e013a74253a..63cf5ac24f0 100644 --- a/lib/private/appframework/utility/controllermethodreflector.php +++ b/lib/private/appframework/utility/controllermethodreflector.php @@ -3,7 +3,7 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Olivier Paroz <github@oparoz.com> - * @author Philipp Knechtges <philipp-dev@knechtges.com> + * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/lib/private/appframework/utility/simplecontainer.php b/lib/private/appframework/utility/simplecontainer.php index c7dff6f4571..5a69d3dbbd2 100644 --- a/lib/private/appframework/utility/simplecontainer.php +++ b/lib/private/appframework/utility/simplecontainer.php @@ -1,6 +1,7 @@ <?php /** * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> diff --git a/lib/private/apphelper.php b/lib/private/apphelper.php index c4ddc1b077e..9084d2b8ab4 100644 --- a/lib/private/apphelper.php +++ b/lib/private/apphelper.php @@ -1,6 +1,7 @@ <?php /** * @author Bart Visscher <bartv@thisnet.nl> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/avatar.php b/lib/private/avatar.php index 133ab4bcd61..55c328b6778 100644 --- a/lib/private/avatar.php +++ b/lib/private/avatar.php @@ -3,12 +3,12 @@ * @author Arthur Schiwon <blizzz@owncloud.com> * @author Christopher Schäpers <kondou@ts.unde.re> * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Lukas Reschke <lukas@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/avatarmanager.php b/lib/private/avatarmanager.php index 42f711ee249..6b33e8d8e8b 100644 --- a/lib/private/avatarmanager.php +++ b/lib/private/avatarmanager.php @@ -1,6 +1,8 @@ <?php /** * @author Arthur Schiwon <blizzz@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Roeland Jago Douma <roeland@famdouma.nl> diff --git a/lib/private/cache/file.php b/lib/private/cache/file.php index 4742128ecbe..69008c7fab5 100644 --- a/lib/private/cache/file.php +++ b/lib/private/cache/file.php @@ -1,16 +1,8 @@ <?php /** - * @author Arthur Schiwon <blizzz@owncloud.com> - * @author Bart Visscher <bartv@thisnet.nl> - * @author Björn Schießle <schiessle@owncloud.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Michael Gapczynski <GapczynskiM@gmail.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <icewind@owncloud.com> - * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Thomas Tanghus <thomas@tanghus.net> - * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 @@ -33,9 +25,12 @@ namespace OC\Cache; use OC\Files\Filesystem; use OC\Files\View; +use OCP\ICache; use OCP\Security\ISecureRandom; -class File { +class File implements ICache { + + /** @var View */ protected $storage; /** @@ -182,9 +177,16 @@ class File { } while (($file = readdir($dh)) !== false) { if ($file != '.' and $file != '..') { - $mtime = $storage->filemtime('/' . $file); - if ($mtime < $now) { - $storage->unlink('/' . $file); + try { + $mtime = $storage->filemtime('/' . $file); + if ($mtime < $now) { + $storage->unlink('/' . $file); + } + } catch (\OCP\Lock\LockedException $e) { + // ignore locked chunks + \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core')); + } catch (\OCP\Files\LockNotAcquiredException $e) { + \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', array('app' => 'core')); } } } diff --git a/lib/private/connector/sabre/auth.php b/lib/private/connector/sabre/auth.php index 5a32a9112ba..8a6eaab5bf8 100644 --- a/lib/private/connector/sabre/auth.php +++ b/lib/private/connector/sabre/auth.php @@ -30,7 +30,12 @@ */ namespace OC\Connector\Sabre; -class Auth extends \Sabre\DAV\Auth\Backend\AbstractBasic { +use Exception; +use Sabre\DAV\Auth\Backend\AbstractBasic; +use Sabre\DAV\Exception\NotAuthenticated; +use Sabre\DAV\Exception\ServiceUnavailable; + +class Auth extends AbstractBasic { const DAV_AUTHENTICATED = 'AUTHENTICATED_TO_DAV_BACKEND'; /** @@ -69,7 +74,7 @@ class Auth extends \Sabre\DAV\Auth\Backend\AbstractBasic { } else { \OC_Util::setUpFS(); //login hooks may need early access to the filesystem if(\OC_User::login($username, $password)) { - // make sure we use owncloud's internal username here + // make sure we use ownCloud's internal username here // and not the HTTP auth supplied one, see issue #14048 $ocUser = \OC_User::getUser(); \OC_Util::setUpFS($ocUser); @@ -99,21 +104,30 @@ class Auth extends \Sabre\DAV\Auth\Backend\AbstractBasic { } /** - * Override function here. We want to cache authentication cookies - * in the syncing client to avoid HTTP-401 roundtrips. - * If the sync client supplies the cookies, then OC_User::isLoggedIn() - * will return true and we can see this WebDAV request as already authenticated, - * even if there are no HTTP Basic Auth headers. - * In other case, just fallback to the parent implementation. - * - * @param \Sabre\DAV\Server $server - * @param $realm - * @return bool - */ + * Override function here. We want to cache authentication cookies + * in the syncing client to avoid HTTP-401 roundtrips. + * If the sync client supplies the cookies, then OC_User::isLoggedIn() + * will return true and we can see this WebDAV request as already authenticated, + * even if there are no HTTP Basic Auth headers. + * In other case, just fallback to the parent implementation. + * + * @param \Sabre\DAV\Server $server + * @param string $realm + * @return bool + * @throws ServiceUnavailable + */ public function authenticate(\Sabre\DAV\Server $server, $realm) { - $result = $this->auth($server, $realm); - return $result; + try { + $result = $this->auth($server, $realm); + return $result; + } catch (NotAuthenticated $e) { + throw $e; + } catch (Exception $e) { + $class = get_class($e); + $msg = $e->getMessage(); + throw new ServiceUnavailable("$class: $msg"); + } } /** diff --git a/lib/private/connector/sabre/copyetagheaderplugin.php b/lib/private/connector/sabre/copyetagheaderplugin.php index 9f5d74654cc..863d4cf3e10 100644 --- a/lib/private/connector/sabre/copyetagheaderplugin.php +++ b/lib/private/connector/sabre/copyetagheaderplugin.php @@ -1,12 +1,23 @@ <?php - /** - * ownCloud + * @author Morris Jobke <hey@morrisjobke.de> + * @author Vincent Petry <pvince81@owncloud.com> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. * - * @author Vincent Petry - * @copyright 2015 Vincent Petry <pvince81@owncloud.com> + * 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/> * - * @license AGPL3 */ namespace OC\Connector\Sabre; diff --git a/lib/private/connector/sabre/custompropertiesbackend.php b/lib/private/connector/sabre/custompropertiesbackend.php index 14989a5bac3..47f34909a08 100644 --- a/lib/private/connector/sabre/custompropertiesbackend.php +++ b/lib/private/connector/sabre/custompropertiesbackend.php @@ -1,5 +1,7 @@ <?php /** + * @author Lukas Reschke <lukas@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * diff --git a/lib/private/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php index e99411068f1..551176e4bd2 100644 --- a/lib/private/connector/sabre/directory.php +++ b/lib/private/connector/sabre/directory.php @@ -4,6 +4,7 @@ * @author Bart Visscher <bartv@thisnet.nl> * @author Björn Schießle <schiessle@owncloud.com> * @author Jakob Sack <mail@jakobsack.de> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 740660f466b..93244bea6ff 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -2,10 +2,7 @@ /** * @author Bart Visscher <bartv@thisnet.nl> * @author Björn Schießle <schiessle@owncloud.com> - * @author chli1 <chli1@users.noreply.github.com> - * @author Chris Wilson <chris+github@qwirx.com> * @author Jakob Sack <mail@jakobsack.de> - * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> @@ -99,7 +96,11 @@ class File extends Node implements IFile { // chunked handling if (isset($_SERVER['HTTP_OC_CHUNKED'])) { - return $this->createFileChunked($data); + try { + return $this->createFileChunked($data); + } catch (\Exception $e) { + $this->convertToSabreException($e); + } } list($partStorage) = $this->fileView->resolvePath($this->path); @@ -128,7 +129,6 @@ class File extends Node implements IFile { $target = $partStorage->fopen($internalPartPath, 'wb'); if ($target === false) { \OC_Log::write('webdav', '\OC\Files\Filesystem::fopen() failed', \OC_Log::ERROR); - $partStorage->unlink($internalPartPath); // because we have no clue about the cause we can only throw back a 500/Internal Server Error throw new Exception('Could not write file contents'); } @@ -141,32 +141,13 @@ class File extends Node implements IFile { if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['REQUEST_METHOD'] !== 'LOCK') { $expected = $_SERVER['CONTENT_LENGTH']; if ($count != $expected) { - $partStorage->unlink($internalPartPath); throw new BadRequest('expected filesize ' . $expected . ' got ' . $count); } } - } catch (NotPermittedException $e) { - // a more general case - due to whatever reason the content could not be written - throw new Forbidden($e->getMessage()); - } catch (EntityTooLargeException $e) { - // the file is too big to be stored - throw new EntityTooLarge($e->getMessage()); - } catch (InvalidContentException $e) { - // the file content is not permitted - throw new UnsupportedMediaType($e->getMessage()); - } catch (InvalidPathException $e) { - // the path for the file was not valid - // TODO: find proper http status code for this case - throw new Forbidden($e->getMessage()); - } catch (LockNotAcquiredException $e) { - // the file is currently being written to by another process - throw new FileLocked($e->getMessage(), $e->getCode(), $e); - } catch (GenericEncryptionException $e) { - // returning 503 will allow retry of the operation at a later point in time - throw new ServiceUnavailable("Encryption not ready: " . $e->getMessage()); - } catch (StorageNotAvailableException $e) { - throw new ServiceUnavailable("Failed to write file contents: " . $e->getMessage()); + } catch (\Exception $e) { + $partStorage->unlink($internalPartPath); + $this->convertToSabreException($e); } try { @@ -195,6 +176,7 @@ class File extends Node implements IFile { try { $this->fileView->changeLock($this->path, ILockingProvider::LOCK_EXCLUSIVE); } catch (LockedException $e) { + $partStorage->unlink($internalPartPath); throw new FileLocked($e->getMessage(), $e->getCode(), $e); } @@ -210,9 +192,9 @@ class File extends Node implements IFile { $partStorage->unlink($internalPartPath); throw new Exception('Could not rename part file to final file'); } - } catch (\OCP\Files\LockNotAcquiredException $e) { - // the file is currently being written to by another process - throw new FileLocked($e->getMessage(), $e->getCode(), $e); + } catch (\Exception $e) { + $partStorage->unlink($internalPartPath); + $this->convertToSabreException($e); } } @@ -383,6 +365,9 @@ class File extends Node implements IFile { \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR); // only delete if an error occurred and the target file was already created if ($fileExists) { + // set to null to avoid double-deletion when handling exception + // stray part file + $partFile = null; $this->fileView->unlink($targetPath); } throw new Exception('Could not rename part file assembled from chunks'); @@ -402,10 +387,11 @@ class File extends Node implements IFile { $info = $this->fileView->getFileInfo($targetPath); return $info->getEtag(); - } catch (StorageNotAvailableException $e) { - throw new ServiceUnavailable("Failed to put file: " . $e->getMessage()); - } catch (LockedException $e) { - throw new FileLocked($e->getMessage(), $e->getCode(), $e); + } catch (\Exception $e) { + if ($partFile) { + $this->fileView->unlink($partFile); + } + $this->convertToSabreException($e); } } @@ -426,4 +412,47 @@ class File extends Node implements IFile { return !$storage->instanceOfStorage('OCA\Files_Sharing\External\Storage') && !$storage->instanceOfStorage('OC\Files\Storage\OwnCloud'); } + + /** + * Convert the given exception to a SabreException instance + * + * @param \Exception $e + * + * @throws \Sabre\DAV\Exception + */ + private function convertToSabreException(\Exception $e) { + if ($e instanceof \Sabre\DAV\Exception) { + throw $e; + } + if ($e instanceof NotPermittedException) { + // a more general case - due to whatever reason the content could not be written + throw new Forbidden($e->getMessage(), 0, $e); + } + if ($e instanceof EntityTooLargeException) { + // the file is too big to be stored + throw new EntityTooLarge($e->getMessage(), 0, $e); + } + if ($e instanceof InvalidContentException) { + // the file content is not permitted + throw new UnsupportedMediaType($e->getMessage(), 0, $e); + } + if ($e instanceof InvalidPathException) { + // the path for the file was not valid + // TODO: find proper http status code for this case + throw new Forbidden($e->getMessage(), 0, $e); + } + if ($e instanceof LockedException || $e instanceof LockNotAcquiredException) { + // the file is currently being written to by another process + throw new FileLocked($e->getMessage(), $e->getCode(), $e); + } + if ($e instanceof GenericEncryptionException) { + // returning 503 will allow retry of the operation at a later point in time + throw new ServiceUnavailable('Encryption not ready: ' . $e->getMessage(), 0, $e); + } + if ($e instanceof StorageNotAvailableException) { + throw new ServiceUnavailable('Failed to write file contents: ' . $e->getMessage(), 0, $e); + } + + throw new \Sabre\DAV\Exception($e->getMessage(), 0, $e); + } } diff --git a/lib/private/connector/sabre/filesplugin.php b/lib/private/connector/sabre/filesplugin.php index 09d931be606..608e8cd9017 100644 --- a/lib/private/connector/sabre/filesplugin.php +++ b/lib/private/connector/sabre/filesplugin.php @@ -1,6 +1,8 @@ <?php /** + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> diff --git a/lib/private/connector/sabre/maintenanceplugin.php b/lib/private/connector/sabre/maintenanceplugin.php index c4c9a5340bc..5b48abbc517 100644 --- a/lib/private/connector/sabre/maintenanceplugin.php +++ b/lib/private/connector/sabre/maintenanceplugin.php @@ -2,6 +2,7 @@ /** * @author Bart Visscher <bartv@thisnet.nl> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> * @@ -24,17 +25,34 @@ namespace OC\Connector\Sabre; -class MaintenancePlugin extends \Sabre\DAV\ServerPlugin -{ +use OCP\IConfig; +use Sabre\DAV\Exception\ServiceUnavailable; +use Sabre\DAV\ServerPlugin; + +class MaintenancePlugin extends ServerPlugin { + + /** @var IConfig */ + private $config; /** * Reference to main server object * - * @var \Sabre\DAV\Server + * @var Server */ private $server; /** + * @param IConfig $config + */ + public function __construct(IConfig $config = null) { + $this->config = $config; + if (is_null($config)) { + $this->config = \OC::$server->getConfig(); + } + } + + + /** * This initializes the plugin. * * This function is called by \Sabre\DAV\Server, after @@ -46,7 +64,6 @@ class MaintenancePlugin extends \Sabre\DAV\ServerPlugin * @return void */ public function initialize(\Sabre\DAV\Server $server) { - $this->server = $server; $this->server->on('beforeMethod', array($this, 'checkMaintenanceMode'), 10); } @@ -55,19 +72,18 @@ class MaintenancePlugin extends \Sabre\DAV\ServerPlugin * This method is called before any HTTP method and returns http status code 503 * in case the system is in maintenance mode. * - * @throws \Sabre\DAV\Exception\ServiceUnavailable - * @internal param string $method + * @throws ServiceUnavailable * @return bool */ public function checkMaintenanceMode() { - if (\OC::$server->getSystemConfig()->getValue('singleuser', false)) { - throw new \Sabre\DAV\Exception\ServiceUnavailable(); + if ($this->config->getSystemValue('singleuser', false)) { + throw new ServiceUnavailable('System in single user mode.'); } - if (\OC_Config::getValue('maintenance', false)) { - throw new \Sabre\DAV\Exception\ServiceUnavailable(); + if ($this->config->getSystemValue('maintenance', false)) { + throw new ServiceUnavailable('System in maintenance mode.'); } if (\OC::checkUpgrade(false)) { - throw new \Sabre\DAV\Exception\ServiceUnavailable('Upgrade needed'); + throw new ServiceUnavailable('Upgrade needed'); } return true; diff --git a/lib/private/connector/sabre/tagsplugin.php b/lib/private/connector/sabre/tagsplugin.php index 6a788b9f3aa..7756eb45bda 100644 --- a/lib/private/connector/sabre/tagsplugin.php +++ b/lib/private/connector/sabre/tagsplugin.php @@ -1,6 +1,5 @@ <?php /** - * @author Morris Jobke <hey@morrisjobke.de> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/console/application.php b/lib/private/console/application.php index f2aacbfc0e6..7c709927219 100644 --- a/lib/private/console/application.php +++ b/lib/private/console/application.php @@ -1,5 +1,24 @@ <?php - +/** + * @author Morris Jobke <hey@morrisjobke.de> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * 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/> + * + */ namespace OC\Console; use OC_App; diff --git a/lib/private/db/migrator.php b/lib/private/db/migrator.php index fcfe5d96279..6a587ede631 100644 --- a/lib/private/db/migrator.php +++ b/lib/private/db/migrator.php @@ -5,6 +5,7 @@ * @author Robin Appelman <icewind@owncloud.com> * @author tbelau666 <thomas.belau@gmx.de> * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Victor Dubiniuk <dubiniuk@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/db/ocsqliteplatform.php b/lib/private/db/ocsqliteplatform.php index fe39e20c864..543f58b90ec 100644 --- a/lib/private/db/ocsqliteplatform.php +++ b/lib/private/db/ocsqliteplatform.php @@ -1,9 +1,23 @@ <?php /** - * Copyright (c) 2015 Robin Appelman <icewind@owncloud.com> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * 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/> + * */ namespace OC\DB; diff --git a/lib/private/encryption/hookmanager.php b/lib/private/encryption/hookmanager.php index 31ecb2fbcf6..d096b7ff3ad 100644 --- a/lib/private/encryption/hookmanager.php +++ b/lib/private/encryption/hookmanager.php @@ -1,5 +1,7 @@ <?php /** + * @author Björn Schießle <schiessle@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/encryption/keys/storage.php b/lib/private/encryption/keys/storage.php index 848d5c0134a..b754462d9b0 100644 --- a/lib/private/encryption/keys/storage.php +++ b/lib/private/encryption/keys/storage.php @@ -1,6 +1,8 @@ <?php /** * @author Björn Schießle <schiessle@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/encryption/manager.php b/lib/private/encryption/manager.php index 4841533cac1..1e0a065e25a 100644 --- a/lib/private/encryption/manager.php +++ b/lib/private/encryption/manager.php @@ -1,6 +1,9 @@ <?php /** * @author Björn Schießle <schiessle@owncloud.com> + * @author Jan-Christoph Borchardt <hey@jancborchardt.net> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/encryption/update.php b/lib/private/encryption/update.php index 02579fd9136..125946ab266 100644 --- a/lib/private/encryption/update.php +++ b/lib/private/encryption/update.php @@ -1,6 +1,8 @@ <?php /** * @author Björn Schießle <schiessle@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/encryption/util.php b/lib/private/encryption/util.php index 80499249561..8bff65428d3 100644 --- a/lib/private/encryption/util.php +++ b/lib/private/encryption/util.php @@ -1,6 +1,9 @@ <?php /** * @author Björn Schießle <schiessle@owncloud.com> + * @author Jan-Christoph Borchardt <hey@jancborchardt.net> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/files.php b/lib/private/files.php index 5a3e1029199..17e2e5a398f 100644 --- a/lib/private/files.php +++ b/lib/private/files.php @@ -1,22 +1,21 @@ <?php /** + * @author Andreas Fischer <bantu@owncloud.com> * @author Arthur Schiwon <blizzz@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> * @author Björn Schießle <schiessle@owncloud.com> - * @author Brice Maron <brice@bmaron.net> * @author dratini0 <dratini0@gmail.com> - * @author Fabian Henze <flyser42@gmx.de> * @author Frank Karlitschek <frank@owncloud.org> * @author Jakob Sack <mail@jakobsack.de> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author josh4trunks <joshruehlig@gmail.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> * @author mvn23 <schopdiedwaas@gmail.com> * @author Nicolai Ehemann <en@enlightened.de> * @author Robin Appelman <icewind@owncloud.com> + * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com> * @author Thibaut GRIDEL <tgridel@free.fr> * @author Thomas Müller <thomas.mueller@tmit.eu> @@ -43,6 +42,9 @@ // TODO: get rid of this using proper composer packages require_once 'mcnetic/phpzipstreamer/ZipStreamer.php'; +use OC\Lock\NoopLockingProvider; +use OCP\Lock\ILockingProvider; + /** * Class for file server access * @@ -82,11 +84,15 @@ class OC_Files { * @param boolean $only_header ; boolean to only send header of the request */ public static function get($dir, $files, $only_header = false) { + $view = \OC\Files\Filesystem::getView(); $xsendfile = false; - if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || - isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || - isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) { - $xsendfile = true; + if (\OC::$server->getLockingProvider() instanceof NoopLockingProvider) { + if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || + isset($_SERVER['MOD_X_SENDFILE2_ENABLED']) || + isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED']) + ) { + $xsendfile = true; + } } if (is_array($files) && count($files) === 1) { @@ -131,7 +137,9 @@ class OC_Files { OC_Util::obEnd(); try { - + if ($get_type === self::FILE) { + $view->lockFile($filename, ILockingProvider::LOCK_SHARED); + } if ($zip or \OC\Files\Filesystem::isReadable($filename)) { self::sendHeaders($filename, $name, $zip); } elseif (!\OC\Files\Filesystem::file_exists($filename)) { @@ -168,7 +176,6 @@ class OC_Files { set_time_limit($executionTime); } else { if ($xsendfile) { - $view = \OC\Files\Filesystem::getView(); /** @var $storage \OC\Files\Storage\Storage */ list($storage) = $view->resolvePath($filename); if ($storage->isLocal()) { @@ -180,6 +187,13 @@ class OC_Files { \OC\Files\Filesystem::readfile($filename); } } + if ($get_type === self::FILE) { + $view->unlockFile($filename, ILockingProvider::LOCK_SHARED); + } + } catch (\OCP\Lock\LockedException $ex) { + $l = \OC::$server->getL10N('core'); + $hint = method_exists($ex, 'getHint') ? $ex->getHint() : ''; + \OC_Template::printErrorPage($l->t('File is currently busy, please try again later'), $hint); } catch (\Exception $ex) { $l = \OC::$server->getL10N('core'); $hint = method_exists($ex, 'getHint') ? $ex->getHint() : ''; diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php index a82ccec2813..680398e383f 100644 --- a/lib/private/files/cache/cache.php +++ b/lib/private/files/cache/cache.php @@ -4,6 +4,7 @@ * @author Bart Visscher <bartv@thisnet.nl> * @author Björn Schießle <schiessle@owncloud.com> * @author Florin Peter <github@florin-peter.de> + * @author Jens-Christian Fischer <jens-christian.fischer@switch.ch> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Michael Gapczynski <GapczynskiM@gmail.com> diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index 4d991e5d11d..90019b649c4 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -2,10 +2,9 @@ /** * @author Arthur Schiwon <blizzz@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> - * @author Björn Schießle <schiessle@owncloud.com> * @author Christopher Schäpers <kondou@ts.unde.re> * @author Florin Peter <github@florin-peter.de> - * @author Georg Ehrke <georg@ownCloud.com> + * @author Georg Ehrke <georg@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> diff --git a/lib/private/files/mapper.php b/lib/private/files/mapper.php index 17831d69abb..2c8760ba40e 100644 --- a/lib/private/files/mapper.php +++ b/lib/private/files/mapper.php @@ -4,7 +4,6 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Thomas Müller <thomas.mueller@tmit.eu> * diff --git a/lib/private/files/objectstore/noopscanner.php b/lib/private/files/objectstore/noopscanner.php index 3a0df13a290..cdcc0149ab3 100644 --- a/lib/private/files/objectstore/noopscanner.php +++ b/lib/private/files/objectstore/noopscanner.php @@ -3,6 +3,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/files/storage/dav.php b/lib/private/files/storage/dav.php index 15f513585fe..d67e6b9f97e 100644 --- a/lib/private/files/storage/dav.php +++ b/lib/private/files/storage/dav.php @@ -5,7 +5,6 @@ * @author Björn Schießle <schiessle@owncloud.com> * @author Carlos Cerrillo <ccerrillo@gmail.com> * @author Felix Moeller <mail@felixmoeller.de> - * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index 315a8e7e25d..53465f8585e 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -7,6 +7,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Klaas Freitag <freitag@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> diff --git a/lib/private/files/storage/localtempfiletrait.php b/lib/private/files/storage/localtempfiletrait.php index e7f51a1807f..86c8b5c8377 100644 --- a/lib/private/files/storage/localtempfiletrait.php +++ b/lib/private/files/storage/localtempfiletrait.php @@ -1,5 +1,7 @@ <?php /** + * @author Lukas Reschke <lukas@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index 4b527357254..932320267e4 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -6,6 +6,7 @@ * @author Clark Tomlinson <fallen013@gmail.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com> diff --git a/lib/private/files/storage/storage.php b/lib/private/files/storage/storage.php index bd809099e1f..f46ac544b56 100644 --- a/lib/private/files/storage/storage.php +++ b/lib/private/files/storage/storage.php @@ -2,6 +2,7 @@ /** * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/files/storage/storagefactory.php b/lib/private/files/storage/storagefactory.php index 31b4090eda2..62b393c845c 100644 --- a/lib/private/files/storage/storagefactory.php +++ b/lib/private/files/storage/storagefactory.php @@ -1,6 +1,5 @@ <?php /** - * @author Björn Schießle <schiessle@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> diff --git a/lib/private/files/storage/temporary.php b/lib/private/files/storage/temporary.php index 0f259905c80..ca348313e45 100644 --- a/lib/private/files/storage/temporary.php +++ b/lib/private/files/storage/temporary.php @@ -27,7 +27,7 @@ namespace OC\Files\Storage; * local storage backend in temporary folder for testing purpose */ class Temporary extends Local{ - public function __construct($arguments) { + public function __construct($arguments = null) { parent::__construct(array('datadir' => \OC_Helper::tmpFolder())); } diff --git a/lib/private/files/storage/wrapper/encryption.php b/lib/private/files/storage/wrapper/encryption.php index 8d1f80c53c0..8818b822fa7 100644 --- a/lib/private/files/storage/wrapper/encryption.php +++ b/lib/private/files/storage/wrapper/encryption.php @@ -1,6 +1,9 @@ <?php /** * @author Björn Schießle <schiessle@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -350,7 +353,7 @@ class Encryption extends Wrapper { $size = $unencryptedSize = 0; $realFile = $this->util->stripPartialFileExtension($path); - $targetExists = $this->file_exists($realFile); + $targetExists = $this->file_exists($realFile) || $this->file_exists($path); $targetIsEncrypted = false; if ($targetExists) { // in case the file exists we require the explicit module as @@ -361,8 +364,12 @@ class Encryption extends Wrapper { $encryptionModule = $this->encryptionManager->getEncryptionModule($encryptionModuleId); } - $size = $this->storage->filesize($path); - $unencryptedSize = $this->filesize($path); + if ($this->file_exists($path)) { + $size = $this->storage->filesize($path); + $unencryptedSize = $this->filesize($path); + } else { + $size = $unencryptedSize = 0; + } } try { @@ -608,7 +615,11 @@ class Encryption extends Wrapper { $header = ''; $realFile = $this->util->stripPartialFileExtension($path); if ($this->storage->file_exists($realFile)) { - $handle = $this->storage->fopen($realFile, 'r'); + $path = $realFile; + } + + if ($this->storage->file_exists($path)) { + $handle = $this->storage->fopen($path, 'r'); $firstBlock = fread($handle, $this->util->getHeaderSize()); fclose($handle); if (substr($firstBlock, 0, strlen(Util::HEADER_START)) === Util::HEADER_START) { diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php index 22d230e7c86..bfa4d768358 100644 --- a/lib/private/files/stream/encryption.php +++ b/lib/private/files/stream/encryption.php @@ -1,8 +1,10 @@ <?php /** * @author Björn Schießle <schiessle@owncloud.com> - * @author Jasper Knockaert <jasper@knockaert.nl> + * @author jknockaert <jasper@knockaert.nl> + * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 61adc6246fb..1706818f03e 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -79,6 +79,8 @@ class View { */ private $lockingProvider; + private $lockingEnabled; + /** * @param string $root * @throws \Exception If $root contains an invalid path @@ -94,6 +96,7 @@ class View { $this->fakeRoot = $root; $this->updater = new Updater($this); $this->lockingProvider = \OC::$server->getLockingProvider(); + $this->lockingEnabled = !($this->lockingProvider instanceof \OC\Lock\NoopLockingProvider); } public function getAbsolutePath($path = '/') { @@ -559,11 +562,12 @@ class View { $this->updater->update($path); - $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); + $this->changeLock($path, ILockingProvider::LOCK_SHARED); if ($this->shouldEmitHooks($path) && $result !== false) { $this->emit_file_hooks_post($exists, $path); } + $this->unlockFile($path, ILockingProvider::LOCK_SHARED); return $result; } else { $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); @@ -615,6 +619,7 @@ class View { public function rename($path1, $path2) { $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1)); $absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2)); + $result = false; if ( Filesystem::isValidPath($path2) and Filesystem::isValidPath($path1) @@ -629,7 +634,12 @@ class View { } $this->lockFile($path1, ILockingProvider::LOCK_SHARED, true); - $this->lockFile($path2, ILockingProvider::LOCK_SHARED, true); + try { + $this->lockFile($path2, ILockingProvider::LOCK_SHARED, true); + } catch (LockedException $e) { + $this->unlockFile($path1, ILockingProvider::LOCK_SHARED); + throw $e; + } $run = true; if ($this->shouldEmitHooks() && (Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2))) { @@ -695,8 +705,8 @@ class View { } } - $this->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE, true); - $this->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE, true); + $this->changeLock($path1, ILockingProvider::LOCK_SHARED, true); + $this->changeLock($path2, ILockingProvider::LOCK_SHARED, true); if ((Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2)) && $result !== false) { if ($this->shouldEmitHooks()) { @@ -714,15 +724,11 @@ class View { ); } } - return $result; - } else { - $this->unlockFile($path1, ILockingProvider::LOCK_SHARED, true); - $this->unlockFile($path2, ILockingProvider::LOCK_SHARED, true); - return false; } - } else { - return false; + $this->unlockFile($path1, ILockingProvider::LOCK_SHARED, true); + $this->unlockFile($path2, ILockingProvider::LOCK_SHARED, true); } + return $result; } /** @@ -737,6 +743,7 @@ class View { public function copy($path1, $path2, $preserveMtime = false) { $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1)); $absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2)); + $result = false; if ( Filesystem::isValidPath($path2) and Filesystem::isValidPath($path1) @@ -788,8 +795,7 @@ class View { $this->updater->update($path2); - $this->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE); - $this->unlockFile($path1, ILockingProvider::LOCK_SHARED); + $this->changeLock($path2, ILockingProvider::LOCK_SHARED); if ($this->shouldEmitHooks() && $result !== false) { \OC_Hook::emit( @@ -802,15 +808,12 @@ class View { ); $this->emit_file_hooks_post($exists, $path2); } - return $result; - } else { + $this->unlockFile($path2, ILockingProvider::LOCK_SHARED); $this->unlockFile($path1, ILockingProvider::LOCK_SHARED); - return false; } - } else { - return false; } + return $result; } /** @@ -1025,7 +1028,9 @@ class View { $this->changeLock($path, ILockingProvider::LOCK_SHARED); } - if ($operation === 'fopen' and is_resource($result)) { + $unlockLater = false; + if ($this->lockingEnabled && $operation === 'fopen' && is_resource($result)) { + $unlockLater = true; $result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) { if (in_array('write', $hooks)) { $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); @@ -1033,16 +1038,19 @@ class View { $this->unlockFile($path, ILockingProvider::LOCK_SHARED); } }); - } else if (in_array('write', $hooks) || in_array('delete', $hooks) || in_array('read', $hooks)) { - $this->unlockFile($path, ILockingProvider::LOCK_SHARED); } - if ($this->shouldEmitHooks($path) && $result !== false) { if ($operation != 'fopen') { //no post hooks for fopen, the file stream is still open $this->runHooks($hooks, $path, true); } } + + if (!$unlockLater + && (in_array('write', $hooks) || in_array('delete', $hooks) || in_array('read', $hooks)) + ) { + $this->unlockFile($path, ILockingProvider::LOCK_SHARED); + } return $result; } else { $this->unlockFile($path, ILockingProvider::LOCK_SHARED); diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php index f8defe476c4..65ae49dfcd2 100644 --- a/lib/private/group/manager.php +++ b/lib/private/group/manager.php @@ -4,10 +4,13 @@ * @author Bart Visscher <bartv@thisnet.nl> * @author Bernhard Posselt <dev@bernhard-posselt.com> * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author macjohnny <estebanmarin@gmx.ch> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> + * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Thomas Müller <thomas.mueller@tmit.eu> * @author voxsim <Simon Vocella> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/group/metadata.php b/lib/private/group/metadata.php index 66eb032d4bf..63447012b0c 100644 --- a/lib/private/group/metadata.php +++ b/lib/private/group/metadata.php @@ -1,6 +1,7 @@ <?php /** * @author Arthur Schiwon <blizzz@owncloud.com> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Stephan Peijnik <speijnik@anexia-it.com> diff --git a/lib/private/helper.php b/lib/private/helper.php index f4de5b0d9f8..4c2f1f509c8 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -16,7 +16,7 @@ * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Olivier Paroz <owncloud@interfasys.ch> + * @author Olivier Paroz <github@oparoz.com> * @author Owen Winkler <a_github@midnightcircus.com> * @author Pellaeon Lin <nfsmwlin@gmail.com> * @author Robin Appelman <icewind@owncloud.com> diff --git a/lib/private/hooks/emittertrait.php b/lib/private/hooks/emittertrait.php index 5d471a3f553..256bf468c4f 100644 --- a/lib/private/hooks/emittertrait.php +++ b/lib/private/hooks/emittertrait.php @@ -1,6 +1,5 @@ <?php /** - * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/installer.php b/lib/private/installer.php index 41f13f0f5f9..bd214be5667 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -227,8 +227,8 @@ class OC_Installer{ \OC::$server->getConfig(), \OC::$server->getLogger() ); - $appData = $ocsClient->getApplication($ocsId); - $download = $ocsClient->getApplicationDownload($ocsId); + $appData = $ocsClient->getApplication($ocsId, \OC_Util::getVersion()); + $download = $ocsClient->getApplicationDownload($ocsId, \OC_Util::getVersion()); if (isset($download['downloadlink']) && trim($download['downloadlink']) !== '') { $download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']); @@ -395,7 +395,7 @@ class OC_Installer{ \OC::$server->getConfig(), \OC::$server->getLogger() ); - $ocsdata = $ocsClient->getApplication($ocsid); + $ocsdata = $ocsClient->getApplication($ocsid, \OC_Util::getVersion()); $ocsversion= (string) $ocsdata['version']; $currentversion=OC_App::getAppVersion($app); if (version_compare($ocsversion, $currentversion, '>')) { diff --git a/lib/private/l10n/string.php b/lib/private/l10n/string.php index f5d80e695ca..77469f88d19 100644 --- a/lib/private/l10n/string.php +++ b/lib/private/l10n/string.php @@ -1,6 +1,7 @@ <?php /** * @author Bart Visscher <bartv@thisnet.nl> + * @author Bernhard Posselt <dev@bernhard-posselt.com> * @author Jakob Sack <mail@jakobsack.de> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> diff --git a/lib/private/legacy/appconfig.php b/lib/private/legacy/appconfig.php index 3bf1fbd739e..54e568d9ff6 100644 --- a/lib/private/legacy/appconfig.php +++ b/lib/private/legacy/appconfig.php @@ -5,6 +5,7 @@ * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/lock/memcachelockingprovider.php b/lib/private/lock/memcachelockingprovider.php index 85b62c8340f..5f2b5e5a4b8 100644 --- a/lib/private/lock/memcachelockingprovider.php +++ b/lib/private/lock/memcachelockingprovider.php @@ -1,6 +1,8 @@ <?php /** + * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/lock/nooplockingprovider.php b/lib/private/lock/nooplockingprovider.php index 4f33b881555..a8571f2aec4 100644 --- a/lib/private/lock/nooplockingprovider.php +++ b/lib/private/lock/nooplockingprovider.php @@ -1,5 +1,7 @@ <?php /** + * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/log.php b/lib/private/log.php index 840713b2eda..dd5cb6efbb9 100644 --- a/lib/private/log.php +++ b/lib/private/log.php @@ -2,7 +2,6 @@ /** * @author Bart Visscher <bartv@thisnet.nl> * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> diff --git a/lib/private/log/errorhandler.php b/lib/private/log/errorhandler.php index 5e92db398f9..d10c44cc0cd 100644 --- a/lib/private/log/errorhandler.php +++ b/lib/private/log/errorhandler.php @@ -3,6 +3,7 @@ * @author Bart Visscher <bartv@thisnet.nl> * @author Björn Schießle <schiessle@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php index 0125164394d..01112ef7f9d 100644 --- a/lib/private/log/owncloud.php +++ b/lib/private/log/owncloud.php @@ -2,18 +2,11 @@ /** * @author Andreas Fischer <bantu@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @author Björn Schießle <schiessle@owncloud.com> - * @author Felix Moeller <mail@felixmoeller.de> - * @author Frank Karlitschek <frank@owncloud.org> * @author Georg Ehrke <georg@owncloud.com> - * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Owen Winkler <a_github@midnightcircus.com> * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Tom Needham <tom@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/log/syslog.php b/lib/private/log/syslog.php index 8595b707d59..863d1d6c201 100644 --- a/lib/private/log/syslog.php +++ b/lib/private/log/syslog.php @@ -1,6 +1,5 @@ <?php /** - * @author Andreas Fischer <bantu@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> diff --git a/lib/private/memcache/arraycache.php b/lib/private/memcache/arraycache.php index 8a3fdd2f7c5..33c8bea8746 100644 --- a/lib/private/memcache/arraycache.php +++ b/lib/private/memcache/arraycache.php @@ -2,6 +2,7 @@ /** * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php index 320657a71ad..5bb7e42c808 100644 --- a/lib/private/memcache/factory.php +++ b/lib/private/memcache/factory.php @@ -6,6 +6,8 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/memcache/nullcache.php b/lib/private/memcache/nullcache.php index f971ffc9b2d..de27b03e71d 100644 --- a/lib/private/memcache/nullcache.php +++ b/lib/private/memcache/nullcache.php @@ -1,7 +1,10 @@ <?php /** * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/memcache/redis.php b/lib/private/memcache/redis.php index 30619c356bc..21477798059 100644 --- a/lib/private/memcache/redis.php +++ b/lib/private/memcache/redis.php @@ -2,7 +2,9 @@ /** * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Michael Telatynski <7t3chguy@gmail.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/mimetypes.list.php b/lib/private/mimetypes.list.php index 5f222cbd835..efb8089420e 100644 --- a/lib/private/mimetypes.list.php +++ b/lib/private/mimetypes.list.php @@ -1,10 +1,12 @@ <?php /** + * @author Aidan Amavi <github@aidanamavi.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Morris Jobke <hey@morrisjobke.de> * @author Normal Ra <normalraw@gmail.com> * @author Olivier Paroz <github@oparoz.com> * @author Robin Appelman <icewind@owncloud.com> + * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Thomas Tanghus <thomas@tanghus.net> * @author tiezdne <oswald.84@t-online.de> * @author Victor Dubiniuk <dubiniuk@owncloud.com> @@ -45,6 +47,7 @@ return array( 'blend' => array('application/x-blender', null), 'bin' => array('application/x-bin', null), 'bmp' => array('image/bmp', null), + 'bpg' => array('image/bpg', null), 'cb7' => array('application/x-cbr', null), 'cba' => array('application/x-cbr', null), 'cbr' => array('application/x-cbr', null), diff --git a/lib/private/ocsclient.php b/lib/private/ocsclient.php index f10a97428e2..18ba4cea003 100644 --- a/lib/private/ocsclient.php +++ b/lib/private/ocsclient.php @@ -7,11 +7,11 @@ * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Kamil Domanski <kdomanski@kdemail.net> * @author Lukas Reschke <lukas@owncloud.com> + * @author Martin Mattel <martin.mattel@diemattels.at> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Sam Tuke <mail@samtuke.com> * @author Thomas Müller <thomas.mueller@tmit.eu> - * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 @@ -106,11 +106,12 @@ class OCSClient { /** * Get all the categories from the OCS server * + * @param array $targetVersion The target ownCloud version * @return array|null an array of category ids or null * @note returns NULL if config value appstoreenabled is set to false * This function returns a list of all the application categories on the OCS server */ - public function getCategories() { + public function getCategories(array $targetVersion) { if (!$this->isAppStoreEnabled()) { return null; } @@ -121,6 +122,9 @@ class OCSClient { $this->getAppStoreUrl() . '/content/categories', [ 'timeout' => 5, + 'query' => [ + 'version' => implode('x', $targetVersion), + ], ] ); } catch(\Exception $e) { @@ -155,9 +159,10 @@ class OCSClient { * @param array $categories * @param int $page * @param string $filter + * @param array $targetVersion The target ownCloud version * @return array An array of application data */ - public function getApplications(array $categories, $page, $filter) { + public function getApplications(array $categories, $page, $filter, array $targetVersion) { if (!$this->isAppStoreEnabled()) { return []; } @@ -169,7 +174,7 @@ class OCSClient { [ 'timeout' => 5, 'query' => [ - 'version' => implode('x', \OC_Util::getVersion()), + 'version' => implode('x', $targetVersion), 'filter' => $filter, 'categories' => implode('x', $categories), 'sortmode' => 'new', @@ -229,11 +234,12 @@ class OCSClient { * Get an the applications from the OCS server * * @param string $id + * @param array $targetVersion The target ownCloud version * @return array|null an array of application data or null * * This function returns an applications from the OCS server */ - public function getApplication($id) { + public function getApplication($id, array $targetVersion) { if (!$this->isAppStoreEnabled()) { return null; } @@ -244,6 +250,9 @@ class OCSClient { $this->getAppStoreUrl() . '/content/data/' . urlencode($id), [ 'timeout' => 5, + 'query' => [ + 'version' => implode('x', $targetVersion), + ], ] ); } catch(\Exception $e) { @@ -284,16 +293,18 @@ class OCSClient { $app['description'] = (string)$tmp->description; $app['detailpage'] = (string)$tmp->detailpage; $app['score'] = (int)$tmp->score; + $app['level'] = (int)$tmp->approved; return $app; } /** * Get the download url for an application from the OCS server - * @param $id + * @param string $id + * @param array $targetVersion The target ownCloud version * @return array|null an array of application data or null */ - public function getApplicationDownload($id) { + public function getApplicationDownload($id, array $targetVersion) { if (!$this->isAppStoreEnabled()) { return null; } @@ -304,6 +315,9 @@ class OCSClient { $url, [ 'timeout' => 5, + 'query' => [ + 'version' => implode('x', $targetVersion), + ], ] ); } catch(\Exception $e) { diff --git a/lib/private/preview.php b/lib/private/preview.php index f3599852838..cc954bc3653 100644 --- a/lib/private/preview.php +++ b/lib/private/preview.php @@ -7,9 +7,8 @@ * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Olivier Paroz <owncloud@interfasys.ch> + * @author Olivier Paroz <github@oparoz.com> * @author Robin Appelman <icewind@owncloud.com> - * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Tobias Kaminsky <tobias@kaminsky.me> * diff --git a/lib/private/preview/bitmap.php b/lib/private/preview/bitmap.php index 3071c788724..12ad4f020eb 100644 --- a/lib/private/preview/bitmap.php +++ b/lib/private/preview/bitmap.php @@ -2,7 +2,7 @@ /** * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> - * @author Olivier Paroz <owncloud@interfasys.ch> + * @author Olivier Paroz <github@oparoz.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/bmp.php b/lib/private/preview/bmp.php index 0547f053cc1..2a24a783d52 100644 --- a/lib/private/preview/bmp.php +++ b/lib/private/preview/bmp.php @@ -1,6 +1,7 @@ <?php /** - * @author Olivier Paroz <owncloud@interfasys.ch> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/gif.php b/lib/private/preview/gif.php index e2b7c7e2ea2..08f6c41d98c 100644 --- a/lib/private/preview/gif.php +++ b/lib/private/preview/gif.php @@ -1,6 +1,7 @@ <?php /** - * @author Olivier Paroz <owncloud@interfasys.ch> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/image.php b/lib/private/preview/image.php index dbaf5deb08d..f9c27e690f6 100644 --- a/lib/private/preview/image.php +++ b/lib/private/preview/image.php @@ -1,9 +1,9 @@ <?php /** * @author Georg Ehrke <georg@owncloud.com> - * @author Olivier Paroz <owncloud@interfasys.ch> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Thomas Tanghus <thomas@tanghus.net> * diff --git a/lib/private/preview/jpeg.php b/lib/private/preview/jpeg.php index 69edd95835c..86e447d3406 100644 --- a/lib/private/preview/jpeg.php +++ b/lib/private/preview/jpeg.php @@ -1,6 +1,7 @@ <?php /** - * @author Olivier Paroz <owncloud@interfasys.ch> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/markdown.php b/lib/private/preview/markdown.php index f73351125ed..f5e74697621 100644 --- a/lib/private/preview/markdown.php +++ b/lib/private/preview/markdown.php @@ -1,7 +1,6 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/movie.php b/lib/private/preview/movie.php index 43e49bfb747..a687fefff65 100644 --- a/lib/private/preview/movie.php +++ b/lib/private/preview/movie.php @@ -1,9 +1,9 @@ <?php /** * @author Georg Ehrke <georg@owncloud.com> - * @author Georg Ehrke <georg@ownCloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/preview/mp3.php b/lib/private/preview/mp3.php index 49667d0dd05..25fe6566e44 100644 --- a/lib/private/preview/mp3.php +++ b/lib/private/preview/mp3.php @@ -1,9 +1,9 @@ <?php /** * @author Georg Ehrke <georg@owncloud.com> - * @author Georg Ehrke <georg@ownCloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * @author Thomas Tanghus <thomas@tanghus.net> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/preview/msoffice2003.php b/lib/private/preview/msoffice2003.php index 1403000f619..dd00cacedf3 100644 --- a/lib/private/preview/msoffice2003.php +++ b/lib/private/preview/msoffice2003.php @@ -1,7 +1,6 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/msoffice2007.php b/lib/private/preview/msoffice2007.php index bd53b59fe62..8fcdabc0484 100644 --- a/lib/private/preview/msoffice2007.php +++ b/lib/private/preview/msoffice2007.php @@ -1,7 +1,6 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/msofficedoc.php b/lib/private/preview/msofficedoc.php index bae41017616..6ce003387fb 100644 --- a/lib/private/preview/msofficedoc.php +++ b/lib/private/preview/msofficedoc.php @@ -1,7 +1,6 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php index 0a61a32df40..f72c5def35f 100644 --- a/lib/private/preview/office.php +++ b/lib/private/preview/office.php @@ -2,6 +2,7 @@ /** * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/opendocument.php b/lib/private/preview/opendocument.php index ce24bb22d8b..21df2b5909a 100644 --- a/lib/private/preview/opendocument.php +++ b/lib/private/preview/opendocument.php @@ -1,7 +1,6 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/png.php b/lib/private/preview/png.php index f40c1dbcc88..a6755671326 100644 --- a/lib/private/preview/png.php +++ b/lib/private/preview/png.php @@ -1,6 +1,7 @@ <?php /** - * @author Olivier Paroz <owncloud@interfasys.ch> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/provider.php b/lib/private/preview/provider.php index ed1f3a1c5c9..d9b80939246 100644 --- a/lib/private/preview/provider.php +++ b/lib/private/preview/provider.php @@ -3,6 +3,8 @@ * @author Georg Ehrke <georg@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/preview/staroffice.php b/lib/private/preview/staroffice.php index 43e2e8e7f3c..b06de79f707 100644 --- a/lib/private/preview/staroffice.php +++ b/lib/private/preview/staroffice.php @@ -1,7 +1,6 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/svg.php b/lib/private/preview/svg.php index 92d21c07385..4e3cba576fb 100644 --- a/lib/private/preview/svg.php +++ b/lib/private/preview/svg.php @@ -1,9 +1,9 @@ <?php /** * @author Georg Ehrke <georg@owncloud.com> - * @author Georg Ehrke <georg@ownCloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/preview/txt.php b/lib/private/preview/txt.php index 684438684fb..0bba570a8c9 100644 --- a/lib/private/preview/txt.php +++ b/lib/private/preview/txt.php @@ -1,9 +1,7 @@ <?php /** * @author Georg Ehrke <georg@owncloud.com> - * @author Georg Ehrke <georg@ownCloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * @author Nmz <nemesiz@nmz.lt> * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> diff --git a/lib/private/preview/xbitmap.php b/lib/private/preview/xbitmap.php index db7b85ff012..8001f21684a 100644 --- a/lib/private/preview/xbitmap.php +++ b/lib/private/preview/xbitmap.php @@ -1,6 +1,7 @@ <?php /** - * @author Olivier Paroz <owncloud@interfasys.ch> + * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/previewmanager.php b/lib/private/previewmanager.php index 78ae12cd2e5..e351c010c85 100644 --- a/lib/private/previewmanager.php +++ b/lib/private/previewmanager.php @@ -2,6 +2,7 @@ /** * @author Joas Schilling <nickvergessen@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * @author Robin Appelman <icewind@owncloud.com> * @author Thomas Müller <thomas.mueller@tmit.eu> * diff --git a/lib/private/repair.php b/lib/private/repair.php index a61ab4becd9..166efd3eb8f 100644 --- a/lib/private/repair.php +++ b/lib/private/repair.php @@ -1,5 +1,6 @@ <?php /** + * @author Arthur Schiwon <blizzz@owncloud.com> * @author Georg Ehrke <georg@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> diff --git a/lib/private/repairstep.php b/lib/private/repairstep.php index ef0dfa9ed5f..25cb91da68e 100644 --- a/lib/private/repairstep.php +++ b/lib/private/repairstep.php @@ -1,6 +1,5 @@ <?php /** - * @author Morris Jobke <hey@morrisjobke.de> * @author Vincent Petry <pvince81@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/response.php b/lib/private/response.php index 5725af2b893..f1a429463f2 100644 --- a/lib/private/response.php +++ b/lib/private/response.php @@ -1,5 +1,6 @@ <?php /** + * @author Andreas Fischer <bantu@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> diff --git a/lib/private/route/route.php b/lib/private/route/route.php index b33360f11ec..86f05b85e5b 100644 --- a/lib/private/route/route.php +++ b/lib/private/route/route.php @@ -1,6 +1,7 @@ <?php /** * @author Bart Visscher <bartv@thisnet.nl> + * @author David Prévot <taffit@debian.org> * @author Felix Moeller <mail@felixmoeller.de> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> diff --git a/lib/private/server.php b/lib/private/server.php index 7e233e64575..6a65895cd69 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -1,5 +1,6 @@ <?php /** + * @author Arthur Schiwon <blizzz@owncloud.com> * @author Bart Visscher <bartv@thisnet.nl> * @author Bernhard Posselt <dev@bernhard-posselt.com> * @author Bernhard Reiter <ockham@raz.or.at> diff --git a/lib/private/servernotavailableexception.php b/lib/private/servernotavailableexception.php index 5a57917d23a..b273f50be98 100644 --- a/lib/private/servernotavailableexception.php +++ b/lib/private/servernotavailableexception.php @@ -15,7 +15,7 @@ * GNU Affero General Public License for more details. * * 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/> * */ diff --git a/lib/private/setup.php b/lib/private/setup.php index 1ffe074dc34..50bf0dceafc 100644 --- a/lib/private/setup.php +++ b/lib/private/setup.php @@ -10,7 +10,6 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Martin Mattel <martin.mattel@diemattels.at> - * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Sean Comeau <sean@ftlnetworks.ca> * @author Serge Martin <edb@sigluy.net> diff --git a/lib/private/setup/abstractdatabase.php b/lib/private/setup/abstractdatabase.php index cc361a62caf..13daf1782fc 100644 --- a/lib/private/setup/abstractdatabase.php +++ b/lib/private/setup/abstractdatabase.php @@ -2,7 +2,6 @@ /** * @author Bart Visscher <bartv@thisnet.nl> * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/setup/mysql.php b/lib/private/setup/mysql.php index 713c779e2cc..b9246a915a6 100644 --- a/lib/private/setup/mysql.php +++ b/lib/private/setup/mysql.php @@ -3,7 +3,6 @@ * @author Bart Visscher <bartv@thisnet.nl> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Michael Göhler <somebody.here@gmx.de> - * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. diff --git a/lib/private/setup/oci.php b/lib/private/setup/oci.php index 4e1cb7de610..791dc7232f5 100644 --- a/lib/private/setup/oci.php +++ b/lib/private/setup/oci.php @@ -4,7 +4,6 @@ * @author Bart Visscher <bartv@thisnet.nl> * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Morris Jobke <hey@morrisjobke.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Victor Dubiniuk <dubiniuk@owncloud.com> * diff --git a/lib/private/setup/postgresql.php b/lib/private/setup/postgresql.php index 082cb6073ff..597e38f43a6 100644 --- a/lib/private/setup/postgresql.php +++ b/lib/private/setup/postgresql.php @@ -4,7 +4,6 @@ * @author Christopher Schäpers <kondou@ts.unde.re> * @author eduardo <eduardo@vnexu.net> * @author Joas Schilling <nickvergessen@owncloud.com> - * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/setup/sqlite.php b/lib/private/setup/sqlite.php index 4a9ead3d510..820a89d4cff 100644 --- a/lib/private/setup/sqlite.php +++ b/lib/private/setup/sqlite.php @@ -1,7 +1,6 @@ <?php /** * @author Bart Visscher <bartv@thisnet.nl> - * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/share/helper.php b/lib/private/share/helper.php index 65167dd7549..26bbca81317 100644 --- a/lib/private/share/helper.php +++ b/lib/private/share/helper.php @@ -4,6 +4,7 @@ * @author Joas Schilling <nickvergessen@owncloud.com> * @author Miguel Prokop <miguel.prokop@vtu.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Vincent Petry <pvince81@owncloud.com> @@ -27,6 +28,8 @@ namespace OC\Share; +use OC\HintException; + class Helper extends \OC\Share\Constants { /** @@ -216,32 +219,74 @@ class Helper extends \OC\Share\Constants { } /** - * Extracts the necessary remote name from a given link + * Strips away a potential file names and trailing slashes: + * - http://localhost + * - http://localhost/ + * - http://localhost/index.php + * - http://localhost/index.php/s/{shareToken} * - * Strips away a potential file name, to allow - * - user - * - user@localhost - * - user@http://localhost - * - user@http://localhost/ - * - user@http://localhost/index.php - * - user@http://localhost/index.php/s/{shareToken} + * all return: http://localhost * * @param string $shareWith * @return string */ - public static function fixRemoteURLInShareWith($shareWith) { - if (strpos($shareWith, '@')) { - list($user, $remote) = explode('@', $shareWith, 2); + protected static function fixRemoteURL($remote) { + $remote = str_replace('\\', '/', $remote); + if ($fileNamePosition = strpos($remote, '/index.php')) { + $remote = substr($remote, 0, $fileNamePosition); + } + $remote = rtrim($remote, '/'); - $remote = str_replace('\\', '/', $remote); - if ($fileNamePosition = strpos($remote, '/index.php')) { - $remote = substr($remote, 0, $fileNamePosition); - } - $remote = rtrim($remote, '/'); + return $remote; + } + + /** + * split user and remote from federated cloud id + * + * @param string $id + * @return array + * @throws HintException + */ + public static function splitUserRemote($id) { + if (strpos($id, '@') === false) { + $l = \OC::$server->getL10N('core'); + $hint = $l->t('Invalid Federated Cloud ID'); + throw new HintException('Invalid Federated Cloud ID', $hint); + } + + // Find the first character that is not allowed in user names + $id = str_replace('\\', '/', $id); + $posSlash = strpos($id, '/'); + $posColon = strpos($id, ':'); + + if ($posSlash === false && $posColon === false) { + $invalidPos = strlen($id); + } else if ($posSlash === false) { + $invalidPos = $posColon; + } else if ($posColon === false) { + $invalidPos = $posSlash; + } else { + $invalidPos = min($posSlash, $posColon); + } + + // Find the last @ before $invalidPos + $pos = $lastAtPos = 0; + while ($lastAtPos !== false && $lastAtPos <= $invalidPos) { + $pos = $lastAtPos; + $lastAtPos = strpos($id, '@', $pos + 1); + } - $shareWith = $user . '@' . $remote; + if ($pos !== false) { + $user = substr($id, 0, $pos); + $remote = substr($id, $pos + 1); + $remote = self::fixRemoteURL($remote); + if (!empty($user) && !empty($remote)) { + return array($user, $remote); + } } - return rtrim($shareWith, '/'); + $l = \OC::$server->getL10N('core'); + $hint = $l->t('Invalid Federated Cloud ID'); + throw new HintException('Invalid Fededrated Cloud ID', $hint); } } diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php index 7120d8493b0..8056260bf17 100644 --- a/lib/private/share/mailnotifications.php +++ b/lib/private/share/mailnotifications.php @@ -2,11 +2,11 @@ /** * @author Björn Schießle <schiessle@owncloud.com> * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Tom Needham <tom@owncloud.com> - * @author Lukas Reschke <lukas@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 954071fdd6c..af7f78b9ff5 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -127,8 +127,8 @@ class Share extends Constants { $cache = false; $view = new \OC\Files\View('/' . $ownerUser . '/files'); - if ($view->file_exists($path)) { - $meta = $view->getFileInfo($path); + $meta = $view->getFileInfo($path); + if ($meta) { $path = substr($meta->getPath(), strlen('/' . $ownerUser . '/files')); } else { // if the file doesn't exists yet we start with the parent folder @@ -372,6 +372,22 @@ class Share extends Constants { if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) { continue; } + if ($fileDependent && (int)$row['file_parent'] === -1) { + // if it is a mount point we need to get the path from the mount manager + $mountManager = \OC\Files\Filesystem::getMountManager(); + $mountPoint = $mountManager->findByStorageId($row['storage_id']); + if (!empty($mountPoint)) { + $path = $mountPoint[0]->getMountPoint(); + $path = trim($path, '/'); + $path = substr($path, strlen($owner) + 1); //normalize path to 'files/foo.txt` + $row['path'] = $path; + } else { + \OC::$server->getLogger()->warning( + 'Could not resolve mount point for ' . $row['storage_id'], + ['app' => 'OCP\Share'] + ); + } + } $shares[] = $row; } @@ -554,6 +570,7 @@ class Share extends Constants { * @param string $itemSourceName * @param \DateTime $expirationDate * @return boolean|string Returns true on success or false on failure, Returns token on success for links + * @throws \OC\HintException when the share type is remote and the shareWith is invalid * @throws \Exception */ public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null, \DateTime $expirationDate = null) { @@ -749,7 +766,8 @@ class Share extends Constants { $token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH, \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER . \OCP\Security\ISecureRandom::CHAR_DIGITS); - $shareWith = Helper::fixRemoteURLInShareWith($shareWith); + list($user, $remote) = Helper::splitUserRemote($shareWith); + $shareWith = $user . '@' . $remote; $shareId = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, $token, $itemSourceName); $send = false; @@ -1300,8 +1318,8 @@ class Share extends Constants { $hookParams['deletedShares'] = $deletedShares; \OC_Hook::emit('OCP\Share', 'post_unshare', $hookParams); if ((int)$item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) { - $urlParts = explode('@', $item['share_with'], 2); - self::sendRemoteUnshare($urlParts[1], $item['id'], $item['token']); + list(, $remote) = Helper::splitUserRemote($item['share_with']); + self::sendRemoteUnshare($remote, $item['id'], $item['token']); } } @@ -1703,11 +1721,20 @@ class Share extends Constants { $row['permissions'] &= ~\OCP\Constants::PERMISSION_SHARE; } // Add display names to result + $row['share_with_displayname'] = $row['share_with']; if ( isset($row['share_with']) && $row['share_with'] != '' && - isset($row['share_with']) && $row['share_type'] === self::SHARE_TYPE_USER) { + $row['share_type'] === self::SHARE_TYPE_USER) { $row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']); - } else { - $row['share_with_displayname'] = $row['share_with']; + } else if(isset($row['share_with']) && $row['share_with'] != '' && + $row['share_type'] === self::SHARE_TYPE_REMOTE) { + $addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']); + foreach ($addressBookEntries as $entry) { + foreach ($entry['CLOUD'] as $cloudID) { + if ($cloudID === $row['share_with']) { + $row['share_with_displayname'] = $entry['FN']; + } + } + } } if ( isset($row['uid_owner']) && $row['uid_owner'] != '') { $row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']); @@ -2279,7 +2306,7 @@ class Share extends Constants { if ($fileDependent) { $select = '`*PREFIX*share`.`id`, `*PREFIX*share`.`parent`, `share_type`, `path`, `storage`, ' . '`share_with`, `uid_owner` , `file_source`, `stime`, `*PREFIX*share`.`permissions`, ' - . '`*PREFIX*storages`.`id` AS `storage_id`'; + . '`*PREFIX*storages`.`id` AS `storage_id`, `*PREFIX*filecache`.`parent` as `file_parent`'; } else { $select = '`id`, `parent`, `share_type`, `share_with`, `uid_owner`, `item_source`, `stime`, `*PREFIX*share`.`permissions`'; } @@ -2289,7 +2316,7 @@ class Share extends Constants { $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,' . ' `share_type`, `share_with`, `file_source`, `file_target`, `path`, `*PREFIX*share`.`permissions`, `stime`,' . ' `expiration`, `token`, `storage`, `mail_send`, `uid_owner`, ' - . '`*PREFIX*storages`.`id` AS `storage_id`'; + . '`*PREFIX*storages`.`id` AS `storage_id`, `*PREFIX*filecache`.`parent` as `file_parent`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `*PREFIX*share`.`permissions`,' . ' `stime`, `file_source`, `expiration`, `token`, `mail_send`, `uid_owner`'; @@ -2306,7 +2333,7 @@ class Share extends Constants { . '`*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`,' . '`file_source`, `path`, `file_target`, `*PREFIX*share`.`permissions`,' . '`stime`, `expiration`, `token`, `storage`, `mail_send`,' - . '`*PREFIX*storages`.`id` AS `storage_id`'; + . '`*PREFIX*storages`.`id` AS `storage_id`, `*PREFIX*filecache`.`parent` as `file_parent`'; } } } @@ -2427,10 +2454,10 @@ class Share extends Constants { */ private static function sendRemoteShare($token, $shareWith, $name, $remote_id, $owner) { - list($user, $remote) = explode('@', $shareWith, 2); + list($user, $remote) = Helper::splitUserRemote($shareWith); if ($user && $remote) { - $url = rtrim($remote, '/') . self::BASE_PATH_TO_SHARE_API . '?format=' . self::RESPONSE_FORMAT; + $url = $remote . self::BASE_PATH_TO_SHARE_API . '?format=' . self::RESPONSE_FORMAT; $local = \OC::$server->getURLGenerator()->getAbsoluteURL('/'); diff --git a/lib/private/template/resourcenotfoundexception.php b/lib/private/template/resourcenotfoundexception.php index 26655b78eee..22f8bcea059 100644 --- a/lib/private/template/resourcenotfoundexception.php +++ b/lib/private/template/resourcenotfoundexception.php @@ -1,6 +1,7 @@ <?php /** * @author Joas Schilling <nickvergessen@owncloud.com> + * @author Morris Jobke <hey@morrisjobke.de> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index 998a683d841..93bf6cbd307 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -9,6 +9,7 @@ * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> + * @author Morris Jobke <hey@morrisjobke.de> * @author Remco Brenninkmeijer <requist1@starmail.nl> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> diff --git a/lib/private/tempmanager.php b/lib/private/tempmanager.php index eeffc6b339d..b8cef8e036e 100644 --- a/lib/private/tempmanager.php +++ b/lib/private/tempmanager.php @@ -1,8 +1,9 @@ <?php /** + * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Olivier Paroz <github@oparoz.com> * @author Robin Appelman <icewind@owncloud.com> - * @author Lukas Reschke <lukas@owncloud.com> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 diff --git a/lib/private/updater.php b/lib/private/updater.php index 00c6569a52f..fa9c1a5176a 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -8,6 +8,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> * @author Robin McCorkell <rmccorkell@karoshi.org.uk> + * @author Steffen Lindner <mail@steffen-lindner.de> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Victor Dubiniuk <dubiniuk@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> @@ -73,7 +74,9 @@ class Updater extends BasicEmitter { * @param IConfig $config * @param ILogger $log */ - public function __construct(HTTPHelper $httpHelper, IConfig $config, ILogger $log = null) { + public function __construct(HTTPHelper $httpHelper, + IConfig $config, + ILogger $log = null) { $this->httpHelper = $httpHelper; $this->log = $log; $this->config = $config; @@ -126,12 +129,12 @@ class Updater extends BasicEmitter { } if (is_null($updaterUrl)) { - $updaterUrl = 'https://apps.owncloud.com/updater.php'; + $updaterUrl = 'https://updates.owncloud.com/server/'; } $this->config->setAppValue('core', 'lastupdatedat', time()); - if ($this->config->getAppValue('core', 'installedat', '') == '') { + if ($this->config->getAppValue('core', 'installedat', '') === '') { $this->config->setAppValue('core', 'installedat', microtime(true)); } @@ -146,22 +149,20 @@ class Updater extends BasicEmitter { //fetch xml data from updater $url = $updaterUrl . '?version=' . $versionString; - // set a sensible timeout of 10 sec to stay responsive even if the update server is down. - - $tmp = array(); + $tmp = []; $xml = $this->httpHelper->getUrlContent($url); if ($xml) { $loadEntities = libxml_disable_entity_loader(true); $data = @simplexml_load_string($xml); libxml_disable_entity_loader($loadEntities); if ($data !== false) { - $tmp['version'] = $data->version; - $tmp['versionstring'] = $data->versionstring; - $tmp['url'] = $data->url; - $tmp['web'] = $data->web; + $tmp['version'] = (string)$data->version; + $tmp['versionstring'] = (string)$data->versionstring; + $tmp['url'] = (string)$data->url; + $tmp['web'] = (string)$data->web; } } else { - $data = array(); + $data = []; } // Cache the result @@ -359,7 +360,6 @@ class Updater extends BasicEmitter { include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php'; } - /** * upgrades all apps within a major ownCloud upgrade. Also loads "priority" * (types authentication, filesystem, logging, in that order) afterwards. @@ -410,6 +410,9 @@ class Updater extends BasicEmitter { * ownCloud version. disable them if not. * This is important if you upgrade ownCloud and have non ported 3rd * party apps installed. + * + * @return array + * @throws \Exception */ private function checkAppsRequirements() { $isCoreUpgrade = $this->isCodeUpgrade(); @@ -446,6 +449,9 @@ class Updater extends BasicEmitter { return $disabledApps; } + /** + * @return bool + */ private function isCodeUpgrade() { $installedVersion = $this->config->getSystemValue('version', '0.0.0'); $currentVersion = implode('.', OC_Util::getVersion()); @@ -455,7 +461,11 @@ class Updater extends BasicEmitter { return false; } - private function upgradeAppStoreApps($disabledApps) { + /** + * @param array $disabledApps + * @throws \Exception + */ + private function upgradeAppStoreApps(array $disabledApps) { foreach($disabledApps as $app) { if (OC_Installer::isUpdateAvailable($app)) { $ocsId = \OC::$server->getConfig()->getAppValue($app, 'ocsid', ''); diff --git a/lib/private/user.php b/lib/private/user.php index 8083b4e40be..7c3cb528a9a 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -10,6 +10,7 @@ * @author Florian Preinstorfer <nblock@archlinux.us> * @author Georg Ehrke <georg@owncloud.com> * @author Jakob Sack <mail@jakobsack.de> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> diff --git a/lib/private/user/backend.php b/lib/private/user/backend.php index 0775bc05588..10bf3e28085 100644 --- a/lib/private/user/backend.php +++ b/lib/private/user/backend.php @@ -134,11 +134,13 @@ abstract class OC_User_Backend implements OC_User_Interface { } /** - * Get a list of all users - * @return array an array of all uids - * - * Get a list of all users. - */ + * Get a list of all users + * + * @param string $search + * @param null|int $limit + * @param null|int $offset + * @return string[] an array of all uids + */ public function getUsers($search = '', $limit = null, $offset = null) { return array(); } @@ -171,10 +173,12 @@ abstract class OC_User_Backend implements OC_User_Interface { } /** - * Get a list of all display names - * @return array an array of all displayNames (value) and the corresponding uids (key) - * * Get a list of all display names and user ids. + * + * @param string $search + * @param string|null $limit + * @param string|null $offset + * @return array an array of all displayNames (value) and the corresponding uids (key) */ public function getDisplayNames($search = '', $limit = null, $offset = null) { $displayNames = array(); diff --git a/lib/private/user/database.php b/lib/private/user/database.php index d080bff04b5..3cf73f939e5 100644 --- a/lib/private/user/database.php +++ b/lib/private/user/database.php @@ -8,6 +8,7 @@ * @author fabian <fabian@web2.0-apps.de> * @author Georg Ehrke <georg@owncloud.com> * @author Jakob Sack <mail@jakobsack.de> + * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Michael Gapczynski <GapczynskiM@gmail.com> @@ -142,10 +143,12 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { } /** - * Get a list of all display names - * @return array an array of all displayNames (value) and the correspondig uids (key) - * * Get a list of all display names and user ids. + * + * @param string $search + * @param string|null $limit + * @param string|null $offset + * @return array an array of all displayNames (value) and the corresponding uids (key) */ public function getDisplayNames($search = '', $limit = null, $offset = null) { $parameters = []; @@ -223,9 +226,11 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend { /** * Get a list of all users - * @return array an array of all uids * - * Get a list of all users. + * @param string $search + * @param null|int $limit + * @param null|int $offset + * @return string[] an array of all uids */ public function getUsers($search = '', $limit = null, $offset = null) { $parameters = []; diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php index 85552740fac..3779f7b5ddf 100644 --- a/lib/private/user/dummy.php +++ b/lib/private/user/dummy.php @@ -108,11 +108,9 @@ class OC_User_Dummy extends OC_User_Backend implements \OCP\IUserBackend { * Get a list of all users * * @param string $search - * @param int $limit - * @param int $offset - * @return string[] with all uids - * - * Get a list of all users. + * @param null|int $limit + * @param null|int $offset + * @return string[] an array of all uids */ public function getUsers($search = '', $limit = null, $offset = null) { if (empty($search)) { diff --git a/lib/private/user/interface.php b/lib/private/user/interface.php index abaca9bad7c..1ccda618e10 100644 --- a/lib/private/user/interface.php +++ b/lib/private/user/interface.php @@ -28,35 +28,37 @@ interface OC_User_Interface { /** - * Check if backend implements actions - * @param int $actions bitwise-or'ed actions - * @return boolean - * - * Returns the supported actions as int to be - * compared with \OC_User_Backend::CREATE_USER etc. - */ + * Check if backend implements actions + * @param int $actions bitwise-or'ed actions + * @return boolean + * + * Returns the supported actions as int to be + * compared with \OC_User_Backend::CREATE_USER etc. + */ public function implementsActions($actions); /** - * delete a user - * @param string $uid The username of the user to delete - * @return bool - */ + * delete a user + * @param string $uid The username of the user to delete + * @return bool + */ public function deleteUser($uid); /** - * Get a list of all users - * @return array an array of all uids - * - * Get a list of all users. - */ + * Get a list of all users + * + * @param string $search + * @param null|int $limit + * @param null|int $offset + * @return string[] an array of all uids + */ public function getUsers($search = '', $limit = null, $offset = null); /** - * check if a user exists - * @param string $uid the username - * @return boolean - */ + * check if a user exists + * @param string $uid the username + * @return boolean + */ public function userExists($uid); /** @@ -67,10 +69,12 @@ interface OC_User_Interface { public function getDisplayName($uid); /** - * Get a list of all display names - * @return array an array of all displayNames (value) and the corresponding uids (key) - * * Get a list of all display names and user ids. + * + * @param string $search + * @param string|null $limit + * @param string|null $offset + * @return array an array of all displayNames (value) and the corresponding uids (key) */ public function getDisplayNames($search = '', $limit = null, $offset = null); diff --git a/lib/private/user/nouserexception.php b/lib/private/user/nouserexception.php index 9452362b4e6..0a077d960bd 100644 --- a/lib/private/user/nouserexception.php +++ b/lib/private/user/nouserexception.php @@ -1,12 +1,23 @@ <?php /** - * ownCloud + * @author Jörn Friedrich Dreyer <jfd@butonic.de> + * @author Morris Jobke <hey@morrisjobke.de> * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING-AGPL file. + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * 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/> * - * @author Jörn Friedrich Dreyer <jfd@owncloud.com> - * @copyright Jörn Friedrich Dreyer 2015 */ namespace OC\User; diff --git a/lib/private/util.php b/lib/private/util.php index 59408c0fc03..9c78ad3ad1c 100644 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -11,10 +11,10 @@ * @author Christian Reiner <github@christian-reiner.info> * @author Christopher Schäpers <kondou@ts.unde.re> * @author Clark Tomlinson <fallen013@gmail.com> + * @author cmeh <cmeh@users.noreply.github.com> * @author Florin Peter <github@florin-peter.de> * @author Frank Karlitschek <frank@owncloud.org> * @author Georg Ehrke <georg@owncloud.com> - * @author Georg Ehrke <georg@ownCloud.com> * @author helix84 <helix84@centrum.sk> * @author Jakob Sack <mail@jakobsack.de> * @author Joas Schilling <nickvergessen@owncloud.com> |