summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2013-08-22 17:55:10 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2013-09-06 16:04:56 +0200
commit597a3cf1ad5443e3e38fc415211b293be19ab8f8 (patch)
tree1bd31be55f5a82a623d9f6ad1125ebf636631fe7
parent83afba50704f86813250054ae94276e62d1b61f8 (diff)
downloadnextcloud-server-597a3cf1ad5443e3e38fc415211b293be19ab8f8.tar.gz
nextcloud-server-597a3cf1ad5443e3e38fc415211b293be19ab8f8.zip
handle part files correctly
-rw-r--r--apps/files_encryption/lib/util.php33
1 files changed, 27 insertions, 6 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index b8d68623493..73191de5681 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -1289,8 +1289,24 @@ class Util {
*/
public function getUidAndFilename($path) {
+ $pathinfo = pathinfo($path);
+ $partfile = false;
+ $parentFolder = false;
+ if ($pathinfo['extension'] === 'part') {
+ // if the real file exists we check this file
+ if ($this->view->file_exists($this->userFilesDir . '/' . $pathinfo['dirname'] . '/' . $pathinfo['filename'])) {
+ $pathToCheck = $pathinfo['dirname'] . '/' . $pathinfo['filename'];
+ } else { // otherwise we look for the parent
+ $pathToCheck = $pathinfo['dirname'];
+ $parentFolder = true;
+ }
+ $partfile = true;
+ } else {
+ $pathToCheck = $path;
+ }
+
$view = new \OC\Files\View($this->userFilesDir);
- $fileOwnerUid = $view->getOwner($path);
+ $fileOwnerUid = $view->getOwner($pathToCheck);
// handle public access
if ($this->isPublic) {
@@ -1319,12 +1335,18 @@ class Util {
$filename = $path;
} else {
-
- $info = $view->getFileInfo($path);
+ $info = $view->getFileInfo($pathToCheck);
$ownerView = new \OC\Files\View('/' . $fileOwnerUid . '/files');
// Fetch real file path from DB
- $filename = $ownerView->getPath($info['fileid']); // TODO: Check that this returns a path without including the user data dir
+ $filename = $ownerView->getPath($info['fileid']);
+ if ($parentFolder) {
+ $filename = $filename . '/'. $pathinfo['filename'];
+ }
+
+ if ($partfile) {
+ $filename = $filename . '.' . $pathinfo['extension'];
+ }
}
@@ -1333,10 +1355,9 @@ class Util {
\OC_Filesystem::normalizePath($filename)
);
}
-
-
}
+
/**
* @brief go recursively through a dir and collect all files and sub files.
* @param string $dir relative to the users files folder