aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_encryption/lib/helper.php')
-rwxr-xr-xapps/files_encryption/lib/helper.php51
1 files changed, 40 insertions, 11 deletions
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php
index 314ac577b2f..0ac6fcf403a 100755
--- a/apps/files_encryption/lib/helper.php
+++ b/apps/files_encryption/lib/helper.php
@@ -165,7 +165,7 @@ class Helper {
public static function isPartialFilePath($path) {
$extension = pathinfo($path, PATHINFO_EXTENSION);
- if ( $extension === 'part' || $extension === 'etmp') {
+ if ( $extension === 'part') {
return true;
} else {
return false;
@@ -183,7 +183,7 @@ class Helper {
public static function stripPartialFileExtension($path) {
$extension = pathinfo($path, PATHINFO_EXTENSION);
- if ( $extension === 'part' || $extension === 'etmp') {
+ if ( $extension === 'part') {
$newLength = strlen($path) - 5; // 5 = strlen(".part") = strlen(".etmp")
$fPath = substr($path, 0, $newLength);
@@ -256,24 +256,53 @@ class Helper {
}
/**
- * @brief get path to the correspondig file in data/user/files
+ * @brief get path to the correspondig file in data/user/files if path points
+ * to a version or to a file in cache
* @param string $path path to a version or a file in the trash
* @return string path to correspondig file relative to data/user/files
*/
public static function getPathToRealFile($path) {
$trimmed = ltrim($path, '/');
$split = explode('/', $trimmed);
-
- if (count($split) < 3 || $split[1] !== "files_versions") {
- return false;
+ $result = false;
+
+ if (count($split) >= 3 && ($split[1] === "files_versions" || $split[1] === 'cache')) {
+ $sliced = array_slice($split, 2);
+ $result = implode('/', $sliced);
+ if ($split[1] === "files_versions") {
+ // we skip user/files
+ $sliced = array_slice($split, 2);
+ $relPath = implode('/', $sliced);
+ //remove the last .v
+ $result = substr($relPath, 0, strrpos($relPath, '.v'));
+ }
+ if ($split[1] === "cache") {
+ // we skip /user/cache/transactionId
+ $sliced = array_slice($split, 3);
+ $result = implode('/', $sliced);
+ //prepare the folders
+ self::mkdirr($path, new \OC\Files\View('/'));
+ }
}
- $sliced = array_slice($split, 2);
- $realPath = implode('/', $sliced);
- //remove the last .v
- $realPath = substr($realPath, 0, strrpos($realPath, '.v'));
+ return $result;
+ }
- return $realPath;
+ /**
+ * @brief create directory recursively
+ * @param string $path
+ * @param \OC\Files\View $view
+ */
+ public static function mkdirr($path, $view) {
+ $dirname = \OC_Filesystem::normalizePath(dirname($path));
+ $dirParts = explode('/', $dirname);
+ $dir = "";
+ foreach ($dirParts as $part) {
+ $dir = $dir . '/' . $part;
+ if (!$view->file_exists($dir)) {
+ $view->mkdir($dir);
+ }
+ }
}
/**