summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/AllConfig.php9
-rw-r--r--lib/private/AppConfig.php2
-rw-r--r--lib/private/Authentication/Token/DefaultTokenCleanupJob.php1
-rw-r--r--lib/private/Encryption/DecryptAll.php4
-rw-r--r--lib/private/Files/Cache/Scanner.php7
-rw-r--r--lib/private/Files/Cache/Updater.php5
-rw-r--r--lib/private/Files/Storage/Common.php3
-rw-r--r--lib/private/Files/Storage/Local.php36
-rw-r--r--lib/private/Files/View.php45
-rw-r--r--lib/private/legacy/helper.php4
10 files changed, 27 insertions, 89 deletions
diff --git a/lib/private/AllConfig.php b/lib/private/AllConfig.php
index e082cea3305..6e99e1ac268 100644
--- a/lib/private/AllConfig.php
+++ b/lib/private/AllConfig.php
@@ -154,7 +154,7 @@ class AllConfig implements \OCP\IConfig {
*
* @param string $appName the appName that we want to store the value under
* @param string $key the key of the value, under which will be saved
- * @param string|float|int $value the value that should be stored
+ * @param string $value the value that should be stored
*/
public function setAppValue($appName, $key, $value) {
\OC::$server->getAppConfig()->setValue($appName, $key, $value);
@@ -198,16 +198,11 @@ class AllConfig implements \OCP\IConfig {
* @param string $userId the userId of the user that we want to store the value under
* @param string $appName the appName that we want to store the value under
* @param string $key the key under which the value is being stored
- * @param string|float|int $value the value that you want to store
+ * @param string $value the value that you want to store
* @param string $preCondition only update if the config value was previously the value passed as $preCondition
* @throws \OCP\PreConditionNotMetException if a precondition is specified and is not met
- * @throws \UnexpectedValueException when trying to store an unexpected value
*/
public function setUserValue($userId, $appName, $key, $value, $preCondition = null) {
- if (!is_int($value) && !is_float($value) && !is_string($value)) {
- throw new \UnexpectedValueException('Only integers, floats and strings are allowed as value');
- }
-
// TODO - FIXME
$this->fixDIInit();
diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php
index f84c8a41f17..24542152ffc 100644
--- a/lib/private/AppConfig.php
+++ b/lib/private/AppConfig.php
@@ -143,7 +143,7 @@ class AppConfig implements IAppConfig {
*
* @param string $app app
* @param string $key key
- * @param string|float|int $value value
+ * @param string $value value
* @return bool True if the value was inserted or updated, false if the value was the same
*/
public function setValue($app, $key, $value) {
diff --git a/lib/private/Authentication/Token/DefaultTokenCleanupJob.php b/lib/private/Authentication/Token/DefaultTokenCleanupJob.php
index 7746d6be915..04b98c6c5a0 100644
--- a/lib/private/Authentication/Token/DefaultTokenCleanupJob.php
+++ b/lib/private/Authentication/Token/DefaultTokenCleanupJob.php
@@ -28,7 +28,6 @@ class DefaultTokenCleanupJob extends Job {
protected function run($argument) {
/* @var $provider DefaultTokenProvider */
- // TODO: add OC\Authentication\Token\IProvider::invalidateOldTokens and query interface
$provider = OC::$server->query('OC\Authentication\Token\DefaultTokenProvider');
$provider->invalidateOldTokens();
}
diff --git a/lib/private/Encryption/DecryptAll.php b/lib/private/Encryption/DecryptAll.php
index 34a3e1bff91..8676bc09575 100644
--- a/lib/private/Encryption/DecryptAll.php
+++ b/lib/private/Encryption/DecryptAll.php
@@ -80,7 +80,7 @@ class DecryptAll {
$this->input = $input;
$this->output = $output;
- if ($user !== '' && $this->userManager->userExists($user) === false) {
+ if (!empty($user) && $this->userManager->userExists($user) === false) {
$this->output->writeln('User "' . $user . '" does not exist. Please check the username and try again');
return false;
}
@@ -141,7 +141,7 @@ class DecryptAll {
$this->output->writeln("\n");
$userList = [];
- if ($user === '') {
+ if (empty($user)) {
$fetchUsersProgress = new ProgressBar($this->output);
$fetchUsersProgress->setFormat(" %message% \n [%bar%]");
diff --git a/lib/private/Files/Cache/Scanner.php b/lib/private/Files/Cache/Scanner.php
index c17f9bfd51b..e6bd118d5a5 100644
--- a/lib/private/Files/Cache/Scanner.php
+++ b/lib/private/Files/Cache/Scanner.php
@@ -38,7 +38,6 @@ use OC\Files\Filesystem;
use OC\Hooks\BasicEmitter;
use OCP\Config;
use OCP\Files\Cache\IScanner;
-use OCP\Files\ForbiddenException;
use OCP\Files\Storage\ILockingStorage;
use OCP\Lock\ILockingProvider;
@@ -141,11 +140,7 @@ class Scanner extends BasicEmitter implements IScanner {
}
}
- try {
- $data = $this->getData($file);
- } catch (ForbiddenException $e) {
- return null;
- }
+ $data = $this->getData($file);
if ($data) {
diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php
index 4e17c4d778d..820941abae1 100644
--- a/lib/private/Files/Cache/Updater.php
+++ b/lib/private/Files/Cache/Updater.php
@@ -231,10 +231,7 @@ class Updater implements IUpdater {
$parentId = $this->cache->getParentId($internalPath);
$parent = dirname($internalPath);
if ($parentId != -1) {
- $mtime = $this->storage->filemtime($parent);
- if ($mtime !== false) {
- $this->cache->update($parentId, array('storage_mtime' => $mtime));
- }
+ $this->cache->update($parentId, array('storage_mtime' => $this->storage->filemtime($parent)));
}
}
}
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index 0c1b69108d4..cec6a42a2c0 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -643,9 +643,6 @@ abstract class Common implements Storage, ILockingStorage {
$data = [];
$data['mimetype'] = $this->getMimeType($path);
$data['mtime'] = $this->filemtime($path);
- if ($data['mtime'] === false) {
- $data['mtime'] = time();
- }
if ($data['mimetype'] == 'httpd/unix-directory') {
$data['size'] = -1; //unknown
} else {
diff --git a/lib/private/Files/Storage/Local.php b/lib/private/Files/Storage/Local.php
index 005b5f9ab91..b07e26a3358 100644
--- a/lib/private/Files/Storage/Local.php
+++ b/lib/private/Files/Storage/Local.php
@@ -33,31 +33,20 @@
*/
namespace OC\Files\Storage;
-
-use OCP\Files\ForbiddenException;
-
/**
* for local filestore, we only have to map the paths
*/
class Local extends \OC\Files\Storage\Common {
protected $datadir;
- protected $dataDirLength;
-
- protected $allowSymlinks = false;
-
- protected $realDataDir;
-
public function __construct($arguments) {
if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) {
throw new \InvalidArgumentException('No data directory set for local storage');
}
$this->datadir = $arguments['datadir'];
- $this->realDataDir = rtrim(realpath($this->datadir), '/') . '/';
if (substr($this->datadir, -1) !== '/') {
$this->datadir .= '/';
}
- $this->dataDirLength = strlen($this->realDataDir);
}
public function __destruct() {
@@ -168,7 +157,7 @@ class Local extends \OC\Files\Storage\Common {
public function filemtime($path) {
clearstatcache($this->getSourcePath($path));
- return $this->file_exists($path) ? filemtime($this->getSourcePath($path)) : false;
+ return filemtime($this->getSourcePath($path));
}
public function touch($path, $mtime = null) {
@@ -199,7 +188,7 @@ class Local extends \OC\Files\Storage\Common {
return '';
}
- $handle = fopen($fileName, 'rb');
+ $handle = fopen($fileName,'rb');
$content = fread($handle, $fileSize);
fclose($handle);
return $content;
@@ -348,27 +337,10 @@ class Local extends \OC\Files\Storage\Common {
*
* @param string $path
* @return string
- * @throws ForbiddenException
*/
public function getSourcePath($path) {
$fullPath = $this->datadir . $path;
- if ($this->allowSymlinks || $path === '') {
- return $fullPath;
- }
- $pathToResolve = $fullPath;
- $realPath = realpath($pathToResolve);
- while ($realPath === false) { // for non existing files check the parent directory
- $pathToResolve = dirname($pathToResolve);
- $realPath = realpath($pathToResolve);
- }
- if ($realPath) {
- $realPath = $realPath . '/';
- }
- if (substr($realPath, 0, $this->dataDirLength) === $this->realDataDir) {
- return $fullPath;
- } else {
- throw new ForbiddenException("Following symlinks is not allowed ('$fullPath' -> '$realPath' not inside '{$this->realDataDir}')", false);
- }
+ return $fullPath;
}
/**
@@ -405,7 +377,7 @@ class Local extends \OC\Files\Storage\Common {
* @return bool
*/
public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
- if ($sourceStorage->instanceOfStorage('\OC\Files\Storage\Local')) {
+ if($sourceStorage->instanceOfStorage('\OC\Files\Storage\Local')){
/**
* @var \OC\Files\Storage\Local $sourceStorage
*/
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index e9daa123470..f738542ea8c 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -337,17 +337,10 @@ class View {
return $this->removeMount($mount, $absolutePath);
}
if ($this->is_dir($path)) {
- $result = $this->basicOperation('rmdir', $path, array('delete'));
+ return $this->basicOperation('rmdir', $path, array('delete'));
} else {
- $result = false;
- }
-
- if (!$result && !$this->file_exists($path)) { //clear ghost files from the cache on delete
- $storage = $mount->getStorage();
- $internalPath = $mount->getInternalPath($absolutePath);
- $storage->getUpdater()->remove($internalPath);
+ return false;
}
- return $result;
}
/**
@@ -436,7 +429,7 @@ class View {
/**
* @param string $path
- * @param int $from
+ * @param int $from
* @param int $to
* @return bool|mixed
* @throws \OCP\Files\InvalidPathException
@@ -448,18 +441,18 @@ class View {
$handle = $this->fopen($path, 'rb');
if ($handle) {
if (fseek($handle, $from) === 0) {
- $chunkSize = 8192; // 8 kB chunks
- $end = $to + 1;
- while (!feof($handle) && ftell($handle) < $end) {
- $len = $end - ftell($handle);
- if ($len > $chunkSize) {
- $len = $chunkSize;
- }
- echo fread($handle, $len);
- flush();
+ $chunkSize = 8192; // 8 kB chunks
+ $end = $to + 1;
+ while (!feof($handle) && ftell($handle) < $end) {
+ $len = $end-ftell($handle);
+ if ($len > $chunkSize) {
+ $len = $chunkSize;
}
- $size = ftell($handle) - $from;
- return $size;
+ echo fread($handle, $len);
+ flush();
+ }
+ $size = ftell($handle) - $from;
+ return $size;
}
throw new \OCP\Files\UnseekableException('fseek error');
@@ -686,15 +679,7 @@ class View {
if ($mount and $mount->getInternalPath($absolutePath) === '') {
return $this->removeMount($mount, $absolutePath);
}
- $result = $this->basicOperation('unlink', $path, array('delete'));
- if (!$result && !$this->file_exists($path)) { //clear ghost files from the cache on delete
- $storage = $mount->getStorage();
- $internalPath = $mount->getInternalPath($absolutePath);
- $storage->getUpdater()->remove($internalPath);
- return true;
- } else {
- return $result;
- }
+ return $this->basicOperation('unlink', $path, array('delete'));
}
/**
diff --git a/lib/private/legacy/helper.php b/lib/private/legacy/helper.php
index 21fb3cbc5ab..f107d47faf7 100644
--- a/lib/private/legacy/helper.php
+++ b/lib/private/legacy/helper.php
@@ -206,9 +206,7 @@ class OC_Helper {
foreach ($files as $fileInfo) {
/** @var SplFileInfo $fileInfo */
- if ($fileInfo->isLink()) {
- unlink($fileInfo->getPathname());
- } else if ($fileInfo->isDir()) {
+ if ($fileInfo->isDir()) {
rmdir($fileInfo->getRealPath());
} else {
unlink($fileInfo->getRealPath());