|
|
|
|
@ -155,7 +155,7 @@ class Keymanager { |
|
|
|
|
if (self::isPartialFilePath($targetPath)) { |
|
|
|
|
|
|
|
|
|
$result = $view->file_put_contents( |
|
|
|
|
$basePath . '/' . self::fixPartialFilePath($targetPath) . '.key', $catfile); |
|
|
|
|
$basePath . '/' . \OCA\Encryption\Helper::fixPartialFilePath($targetPath) . '.key', $catfile); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
@ -169,29 +169,6 @@ class Keymanager { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @brief Remove .path extension from a file path |
|
|
|
|
* @param string $path Path that may identify a .part file |
|
|
|
|
* @return string File path without .part extension |
|
|
|
|
* @note this is needed for reusing keys |
|
|
|
|
*/ |
|
|
|
|
public static function fixPartialFilePath($path) { |
|
|
|
|
|
|
|
|
|
if (preg_match('/\.part$/', $path) || preg_match('/\.etmp$/', $path)) { |
|
|
|
|
|
|
|
|
|
$newLength = strlen($path) - 5; |
|
|
|
|
$fPath = substr($path, 0, $newLength); |
|
|
|
|
|
|
|
|
|
return $fPath; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
return $path; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @brief Check if a path is a .part file |
|
|
|
|
* @param string $path Path that may identify a .part file |
|
|
|
|
@ -199,14 +176,11 @@ class Keymanager { |
|
|
|
|
*/ |
|
|
|
|
public static function isPartialFilePath($path) { |
|
|
|
|
|
|
|
|
|
if (preg_match('/\.part$/', $path) || preg_match('/\.etmp$/', $path)) { |
|
|
|
|
|
|
|
|
|
$extension = pathinfo($path, PATHINFO_EXTENSION); |
|
|
|
|
if ( $extension === 'part' || $extension === 'etmp') { |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
@ -226,7 +200,7 @@ class Keymanager { |
|
|
|
|
$util = new Util($view, \OCP\User::getUser()); |
|
|
|
|
|
|
|
|
|
list($owner, $filename) = $util->getUidAndFilename($filePath); |
|
|
|
|
$filename = self::fixPartialFilePath($filename); |
|
|
|
|
$filename = \OCA\Encryption\Helper::fixPartialFilePath($filename); |
|
|
|
|
$filePath_f = ltrim($filename, '/'); |
|
|
|
|
|
|
|
|
|
// in case of system wide mount points the keys are stored directly in the data directory |
|
|
|
|
@ -386,7 +360,7 @@ class Keymanager { |
|
|
|
|
|
|
|
|
|
// try reusing key file if part file |
|
|
|
|
if (self::isPartialFilePath($shareKeyPath)) { |
|
|
|
|
$writePath = $basePath . '/' . self::fixPartialFilePath($shareKeyPath) . '.' . $userId . '.shareKey'; |
|
|
|
|
$writePath = $basePath . '/' . \OCA\Encryption\Helper::fixPartialFilePath($shareKeyPath) . '.' . $userId . '.shareKey'; |
|
|
|
|
} else { |
|
|
|
|
$writePath = $basePath . '/' . $shareKeyPath . '.' . $userId . '.shareKey'; |
|
|
|
|
} |
|
|
|
|
@ -422,7 +396,7 @@ class Keymanager { |
|
|
|
|
$util = new Util($view, \OCP\User::getUser()); |
|
|
|
|
|
|
|
|
|
list($owner, $filename) = $util->getUidAndFilename($filePath); |
|
|
|
|
$filename = self::fixPartialFilePath($filename); |
|
|
|
|
$filename = \OCA\Encryption\Helper::fixPartialFilePath($filename); |
|
|
|
|
// in case of system wide mount points the keys are stored directly in the data directory |
|
|
|
|
if ($util->isSystemWideMountPoint($filename)) { |
|
|
|
|
$shareKeyPath = '/files_encryption/share-keys/' . $filename . '.' . $userId . '.shareKey'; |
|
|
|
|
|