Merge pull request #2122 from nextcloud/downstream-26520
Hack to prevent warning for read-only wrapper in public links
This commit is contained in:
commit
8a02647e65
|
@ -73,14 +73,12 @@ $server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, func
|
|||
$isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
|
||||
$fileId = $share->getNodeId();
|
||||
|
||||
/*
|
||||
if (!$isReadable) {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
|
||||
$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
|
||||
\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
|
||||
return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
|
||||
});
|
||||
\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
|
||||
|
||||
OC_Util::setupFS($owner);
|
||||
$ownerView = \OC\Files\Filesystem::getView();
|
||||
|
|
|
@ -63,9 +63,12 @@ $path = $data['realPath'];
|
|||
|
||||
$isWritable = $share->getPermissions() & (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_CREATE);
|
||||
if (!$isWritable) {
|
||||
// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
|
||||
$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
|
||||
\OC\Files\Filesystem::addStorageWrapper('readonly', function ($mountPoint, $storage) {
|
||||
return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => \OCP\Constants::PERMISSION_READ + \OCP\Constants::PERMISSION_SHARE));
|
||||
});
|
||||
\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
|
||||
}
|
||||
|
||||
$rootInfo = \OC\Files\Filesystem::getFileInfo($path);
|
||||
|
|
|
@ -214,10 +214,13 @@ class Filesystem {
|
|||
|
||||
/**
|
||||
* @param bool $shouldLog
|
||||
* @return bool previous value
|
||||
* @internal
|
||||
*/
|
||||
public static function logWarningWhenAddingStorageWrapper($shouldLog) {
|
||||
self::$logWarningWhenAddingStorageWrapper = (bool)$shouldLog;
|
||||
$previousValue = self::$logWarningWhenAddingStorageWrapper;
|
||||
self::$logWarningWhenAddingStorageWrapper = (bool) $shouldLog;
|
||||
return $previousValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,7 +229,7 @@ class Filesystem {
|
|||
* @param int $priority
|
||||
*/
|
||||
public static function addStorageWrapper($wrapperName, $wrapper, $priority = 50) {
|
||||
if (self::$logWarningWhenAddingStorageWrapper && $wrapperName !== 'readonly') {
|
||||
if (self::$logWarningWhenAddingStorageWrapper) {
|
||||
\OC::$server->getLogger()->warning("Storage wrapper '{wrapper}' was not registered via the 'OC_Filesystem - preSetup' hook which could cause potential problems.", [
|
||||
'wrapper' => $wrapperName,
|
||||
'app' => 'filesystem',
|
||||
|
|
Loading…
Reference in New Issue