aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/lib/util.php
diff options
context:
space:
mode:
authorFlorin Peter <github@florin-peter.de>2013-06-03 18:42:13 +0200
committerFlorin Peter <github@florin-peter.de>2013-06-03 18:42:13 +0200
commitdc8bcf0688c80220a864b5829ecefbd2c0d70ea4 (patch)
tree6d9cbc1a65a315af07bce7595ea0de195389e554 /apps/files_encryption/lib/util.php
parent1e601cd6f1a4be0f3736467e08c6de8603b6aad0 (diff)
downloadnextcloud-server-dc8bcf0688c80220a864b5829ecefbd2c0d70ea4.tar.gz
nextcloud-server-dc8bcf0688c80220a864b5829ecefbd2c0d70ea4.zip
reformat code
Diffstat (limited to 'apps/files_encryption/lib/util.php')
-rw-r--r--apps/files_encryption/lib/util.php45
1 files changed, 26 insertions, 19 deletions
diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 6923b81b926..6446e83222e 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -302,7 +302,7 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
- if($result->numRows() > 0) {
+ if ($result->numRows() > 0) {
$row = $result->fetchRow();
if (isset($row['recovery_enabled'])) {
$recoveryEnabled[] = $row['recovery_enabled'];
@@ -442,7 +442,7 @@ class Util {
// If the file uses old
// encryption system
- } elseif ( Crypt::isLegacyEncryptedContent( $data, $relPath ) ) {
+ } elseif (Crypt::isLegacyEncryptedContent($data, $relPath)) {
$found['legacy'][] = array(
'name' => $file,
@@ -573,7 +573,9 @@ class Util {
// get relative path
$relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
- if (isset($pathParts[2]) && $pathParts[2] === 'files' && $this->view->file_exists($path) && $this->isEncryptedPath($path)) {
+ if (isset($pathParts[2]) && $pathParts[2] === 'files' && $this->view->file_exists($path)
+ && $this->isEncryptedPath($path)
+ ) {
// get the size from filesystem
$fullPath = $this->view->getLocalFile($path);
@@ -643,7 +645,7 @@ class Util {
return $result;
}
-
+
/**
* @param $path
* @return bool
@@ -687,28 +689,32 @@ class Util {
$relPath = $plainFile['path'];
//relative to /data
- $rawPath = '/'.$this->userId . '/files/' . $plainFile['path'];
+ $rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
// Open plain file handle for binary reading
- $plainHandle = $this->view->fopen( $rawPath, 'rb' );
+ $plainHandle = $this->view->fopen($rawPath, 'rb');
// Open enc file handle for binary writing, with same filename as original plain file
- $encHandle = fopen( 'crypt://' . $relPath.'.tmp', 'wb' );
+ $encHandle = fopen('crypt://' . $relPath . '.tmp', 'wb');
// Move plain file to a temporary location
- $size = stream_copy_to_stream( $plainHandle, $encHandle );
+ $size = stream_copy_to_stream($plainHandle, $encHandle);
fclose($encHandle);
$fakeRoot = $this->view->getRoot();
- $this->view->chroot('/'.$this->userId.'/files');
+ $this->view->chroot('/' . $this->userId . '/files');
$this->view->rename($relPath . '.tmp', $relPath);
$this->view->chroot($fakeRoot);
// Add the file to the cache
- \OC\Files\Filesystem::putFileInfo( $relPath, array( 'encrypted' => true, 'size' => $size, 'unencrypted_size' => $size ) );
+ \OC\Files\Filesystem::putFileInfo($relPath, array(
+ 'encrypted' => true,
+ 'size' => $size,
+ 'unencrypted_size' => $size
+ ));
}
// Encrypt legacy encrypted files
@@ -735,7 +741,7 @@ class Util {
$publicKeys = Keymanager::getPublicKeys($this->view, $uniqueUserIds);
// Recrypt data, generate catfile
- $recrypted = Crypt::legacyKeyRecryptKeyfile( $legacyData, $legacyPassphrase, $publicKeys );
+ $recrypted = Crypt::legacyKeyRecryptKeyfile($legacyData, $legacyPassphrase, $publicKeys);
$rawPath = $legacyFile['path'];
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($rawPath);
@@ -831,7 +837,7 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
- if($result->numRows() > 0) {
+ if ($result->numRows() > 0) {
$row = $result->fetchRow();
$path = substr($row['path'], strlen('files'));
}
@@ -1102,7 +1108,7 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
- if($result->numRows() > 0) {
+ if ($result->numRows() > 0) {
$row = $result->fetchRow();
if (isset($row['migration_status'])) {
$migrationStatus[] = $row['migration_status'];
@@ -1191,7 +1197,8 @@ class Util {
$result = array();
- $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath($this->userFilesDir . '/' . $dir));
+ $content = $this->view->getDirectoryContent(\OC\Files\Filesystem::normalizePath(
+ $this->userFilesDir . '/' . $dir));
// handling for re shared folders
$pathSplit = explode('/', $dir);
@@ -1252,7 +1259,7 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
- if($result->numRows() > 0) {
+ if ($result->numRows() > 0) {
$row = $result->fetchRow();
}
}
@@ -1278,7 +1285,7 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
- if($result->numRows() > 0) {
+ if ($result->numRows() > 0) {
$row = $result->fetchRow();
}
}
@@ -1303,7 +1310,7 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
- if($result->numRows() > 0) {
+ if ($result->numRows() > 0) {
$source = $result->fetchRow();
}
}
@@ -1324,7 +1331,7 @@ class Util {
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
} else {
- if($result->numRows() > 0) {
+ if ($result->numRows() > 0) {
$item = $result->fetchRow();
}
}
@@ -1534,7 +1541,7 @@ class Util {
list($storage, $internalPath) = \OC\Files\Cache\Cache::getById($id);
$mount = \OC\Files\Filesystem::getMountByStorageId($storage);
$mountPoint = $mount[0]->getMountPoint();
- $path = \OC\Files\Filesystem::normalizePath($mountPoint.'/'.$internalPath);
+ $path = \OC\Files\Filesystem::normalizePath($mountPoint . '/' . $internalPath);
// reformat the path to be relative e.g. /user/files/folder becomes /folder/
$relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);