summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-15 13:31:56 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-15 13:31:56 +0100
commit6824704699a87dbccabe61319610141e7411b90e (patch)
tree5030163c53cbb91f7ea518b4046666148d504291 /apps/files_versions
parent41106c1967cb7cbee20dd56666d9605eabdc4460 (diff)
parent94200b682cacbbb5fe673fad64ec5bf1d12f34fc (diff)
downloadnextcloud-server-6824704699a87dbccabe61319610141e7411b90e.tar.gz
nextcloud-server-6824704699a87dbccabe61319610141e7411b90e.zip
Merge pull request #21117 from owncloud/owner-file-exists
Only return an owner if the file exists + improved getUidAndFilename
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/storage.php38
1 files changed, 15 insertions, 23 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index 74bf8fea49d..35b3110928b 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -41,10 +41,10 @@
namespace OCA\Files_Versions;
+use OC\Files\Filesystem;
use OCA\Files_Versions\AppInfo\Application;
use OCA\Files_Versions\Command\Expire;
use OCP\Lock\ILockingProvider;
-use OCP\Files\NotFoundException;
class Storage {
@@ -81,18 +81,7 @@ class Storage {
* @throws \OC\User\NoUserException
*/
public static function getUidAndFilename($filename) {
- $uid = \OC\Files\Filesystem::getOwner($filename);
- \OC\Files\Filesystem::initMountPoints($uid);
- if ( $uid != \OCP\User::getUser() ) {
- $info = \OC\Files\Filesystem::getFileInfo($filename);
- $ownerView = new \OC\Files\View('/'.$uid.'/files');
- try {
- $filename = $ownerView->getPath($info['fileid']);
- } catch (NotFoundException $e) {
- $filename = null;
- }
- }
- return [$uid, $filename];
+ return Filesystem::getView()->getUidAndFilename($filename);
}
/**
@@ -145,7 +134,12 @@ class Storage {
// to get the right target
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if ($ext === 'part') {
- $filename = substr($filename, 0, strlen($filename)-5);
+ $filename = substr($filename, 0, strlen($filename) - 5);
+ }
+
+ // we only handle existing files
+ if (! Filesystem::file_exists($filename) || Filesystem::is_dir($filename)) {
+ return false;
}
list($uid, $filename) = self::getUidAndFilename($filename);
@@ -153,15 +147,8 @@ class Storage {
$files_view = new \OC\Files\View('/'.$uid .'/files');
$users_view = new \OC\Files\View('/'.$uid);
- // check if filename is a directory
- if($files_view->is_dir($filename)) {
- return false;
- }
-
- // we should have a source file to work with, and the file shouldn't
- // be empty
- $fileExists = $files_view->file_exists($filename);
- if (!($fileExists && $files_view->filesize($filename) > 0)) {
+ // no use making versions for empty files
+ if ($files_view->filesize($filename) === 0) {
return false;
}
@@ -648,6 +635,11 @@ class Storage {
$expiration = self::getExpiration();
if($config->getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' && $expiration->isEnabled()) {
+
+ if (!Filesystem::file_exists($filename)) {
+ return false;
+ }
+
list($uid, $filename) = self::getUidAndFilename($filename);
if (empty($filename)) {
// file maybe renamed or deleted