Fixes to code formatting and indentation
This commit is contained in:
parent
92e28839ff
commit
163fe64016
|
@ -125,16 +125,23 @@ class Keymanager {
|
|||
// create all parent folders
|
||||
$info = pathinfo( $basePath . '/' . $targetPath );
|
||||
$keyfileFolderName = $view->getLocalFolder( $info['dirname'] );
|
||||
|
||||
if ( ! file_exists( $keyfileFolderName ) ) {
|
||||
|
||||
mkdir( $keyfileFolderName, 0750, true );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// try reusing key file if part file
|
||||
if ( self::isPartialFilePath( $targetPath ) ) {
|
||||
|
||||
$result = $view->file_put_contents( $basePath . '/' . self::fixPartialFilePath( $targetPath ) . '.key', $catfile );
|
||||
|
||||
} else {
|
||||
|
||||
$result = $view->file_put_contents( $basePath . '/' . $targetPath . '.key', $catfile );
|
||||
|
||||
}
|
||||
|
||||
\OC_FileProxy::$enabled = $proxyStatus;
|
||||
|
@ -149,14 +156,15 @@ class Keymanager {
|
|||
* @return string File path without .part extension
|
||||
* @note this is needed for reusing keys
|
||||
*/
|
||||
public static function fixPartialFilePath($path)
|
||||
{
|
||||
public static function fixPartialFilePath( $path ) {
|
||||
|
||||
if (preg_match('/\.part$/', $path)) {
|
||||
|
||||
$newLength = strlen($path) - 5;
|
||||
$fPath = substr($path, 0, $newLength);
|
||||
|
||||
return $fPath;
|
||||
|
||||
} else {
|
||||
|
||||
return $path;
|
||||
|
@ -165,12 +173,21 @@ class Keymanager {
|
|||
|
||||
}
|
||||
|
||||
public static function isPartialFilePath($path)
|
||||
{
|
||||
/**
|
||||
* @brief Check if a path is a .part file
|
||||
* @param string $path Path that may identify a .part file
|
||||
* @return bool
|
||||
*/
|
||||
public static function isPartialFilePath( $path ) {
|
||||
|
||||
if ( preg_match('/\.part$/', $path ) ) {
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -188,10 +205,15 @@ class Keymanager {
|
|||
|
||||
// try reusing key file if part file
|
||||
if ( self::isPartialFilePath( $filePath ) ) {
|
||||
|
||||
$result = self::getFileKey( $view, $userId, self::fixPartialFilePath( $filePath ) );
|
||||
|
||||
if ( $result ) {
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$util = new Util($view, \OCP\User::getUser());
|
||||
|
@ -279,6 +301,7 @@ class Keymanager {
|
|||
\OC_FileProxy::$enabled = $proxyStatus;
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -330,7 +353,7 @@ class Keymanager {
|
|||
*/
|
||||
public static function setShareKey( \OC_FilesystemView $view, $path, $userId, $shareKey ) {
|
||||
|
||||
//here we need the currently logged in user, while userId can be a different user
|
||||
// Here we need the currently logged in user, while userId can be a different user
|
||||
$util = new Util( $view, \OCP\User::getUser() );
|
||||
|
||||
list( $owner, $filename ) = $util->getUidAndFilename( $path );
|
||||
|
@ -341,9 +364,13 @@ class Keymanager {
|
|||
|
||||
// try reusing key file if part file
|
||||
if(self::isPartialFilePath($shareKeyPath)) {
|
||||
|
||||
$writePath = $basePath . '/' . self::fixPartialFilePath($shareKeyPath) . '.' . $userId . '.shareKey';
|
||||
|
||||
} else {
|
||||
|
||||
$writePath = $basePath . '/' . $shareKeyPath . '.' . $userId . '.shareKey';
|
||||
|
||||
}
|
||||
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
|
@ -409,10 +436,15 @@ class Keymanager {
|
|||
|
||||
// try reusing key file if part file
|
||||
if(self::isPartialFilePath($filePath)) {
|
||||
|
||||
$result = self::getShareKey($view, $userId, self::fixPartialFilePath($filePath));
|
||||
|
||||
if($result) {
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
|
|
Loading…
Reference in New Issue