Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-02-03 16:39:05 +0400
committerBjoern Schiessle <schiessle@owncloud.com>2014-02-05 17:32:32 +0400
commitf8249867422a8b20c7e254785f7dc53946a8fec4 (patch)
treeabbf7fe86acd0c8d470b6744e48444b961552b73 /apps/files_encryption/lib
parent5e788ae1fa0eb729d2563dbe79813b919b1dc139 (diff)
add function to extract filename from sharekey name + tests
Diffstat (limited to 'apps/files_encryption/lib')
-rwxr-xr-xapps/files_encryption/lib/keymanager.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php
index 17b8180bfdd..7abc565f609 100755
--- a/apps/files_encryption/lib/keymanager.php
+++ b/apps/files_encryption/lib/keymanager.php
@@ -437,7 +437,7 @@ class Keymanager {
$filename = pathinfo($filePath, PATHINFO_BASENAME);
foreach($view->getDirectoryContent($parentDir) as $content) {
$path = $content['path'];
- if (strpos($content['name'], $filename) === 0) {
+ if (self::getFilenameFromShareKey($content['name']) === $filename) {
$view->unlink('/' . $userId . '/' . $path);
}
}
@@ -538,4 +538,20 @@ class Keymanager {
return $targetPath;
}
+
+ /**
+ * @brief extract filename from share key name
+ * @param string $shareKey (filename.userid.sharekey)
+ * @return mixed filename or false
+ */
+ protected static function getFilenameFromShareKey($shareKey) {
+ $parts = explode('.', $shareKey);
+
+ $filename = false;
+ if(count($parts) > 2) {
+ $filename = implode('.', array_slice($parts, 0, count($parts)-2));
+ }
+
+ return $filename;
+ }
}