2011-10-21 15:02:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2013-05-19 23:24:36 +00:00
|
|
|
* ownCloud
|
|
|
|
*
|
2014-03-27 12:49:48 +00:00
|
|
|
* @author Bjoern Schiessle, Sam Tuke, Robin Appelman
|
|
|
|
* @copyright 2012 Sam Tuke <samtuke@owncloud.com>
|
|
|
|
* 2012 Robin Appelman <icewind1991@gmail.com>
|
|
|
|
* 2014 Bjoern Schiessle <schiessle@owncloud.com>
|
2013-05-19 23:24:36 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 3 of the License, or any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2011-10-21 15:02:11 +00:00
|
|
|
|
2013-01-30 18:52:02 +00:00
|
|
|
/**
|
2013-05-19 23:24:36 +00:00
|
|
|
* @brief Encryption proxy which handles filesystem operations before and after
|
|
|
|
* execution and encrypts, and handles keyfiles accordingly. Used for
|
|
|
|
* webui.
|
|
|
|
*/
|
2013-01-30 18:52:02 +00:00
|
|
|
|
2012-10-17 15:35:19 +00:00
|
|
|
namespace OCA\Encryption;
|
2012-07-25 17:28:56 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
/**
|
|
|
|
* Class Proxy
|
|
|
|
* @package OCA\Encryption
|
|
|
|
*/
|
2013-05-27 15:26:58 +00:00
|
|
|
class Proxy extends \OC_FileProxy {
|
2012-07-25 15:25:24 +00:00
|
|
|
|
2014-01-23 14:45:34 +00:00
|
|
|
private static $unencryptedSizes = array(); // remember unencrypted size
|
2014-02-27 12:58:51 +00:00
|
|
|
private static $fopenMode = array(); // remember the fopen mode
|
2014-03-27 12:49:48 +00:00
|
|
|
private static $enableEncryption = false; // Enable encryption for the given path
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2011-11-24 00:44:54 +00:00
|
|
|
/**
|
2012-07-11 16:51:27 +00:00
|
|
|
* Check if a file requires encryption
|
2011-11-24 00:44:54 +00:00
|
|
|
* @param string $path
|
2014-03-27 12:49:48 +00:00
|
|
|
* @param string $mode type of access
|
2011-11-24 00:44:54 +00:00
|
|
|
* @return bool
|
2012-07-11 16:51:27 +00:00
|
|
|
*
|
2014-03-27 12:49:48 +00:00
|
|
|
* Tests if server side encryption is enabled, and if we should call the
|
|
|
|
* crypt stream wrapper for the given file
|
2011-11-24 00:44:54 +00:00
|
|
|
*/
|
2014-03-27 12:49:48 +00:00
|
|
|
private static function shouldEncrypt($path, $mode = 'w') {
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-11-20 23:23:38 +00:00
|
|
|
$userId = Helper::getUser($path);
|
2014-04-28 12:40:10 +00:00
|
|
|
$session = new Session(new \OC\Files\View());
|
2013-11-20 23:23:38 +00:00
|
|
|
|
2014-03-27 12:49:48 +00:00
|
|
|
// don't call the crypt stream wrapper, if...
|
|
|
|
if (
|
2014-04-28 12:40:10 +00:00
|
|
|
$session->getInitialized() !== Session::INIT_SUCCESSFUL // encryption successful initialized
|
2014-03-27 12:49:48 +00:00
|
|
|
|| Crypt::mode() !== 'server' // we are not in server-side-encryption mode
|
|
|
|
|| strpos($path, '/' . $userId . '/files') !== 0 // path is not in files/
|
|
|
|
|| substr($path, 0, 8) === 'crypt://' // we are already in crypt mode
|
|
|
|
) {
|
2012-04-18 14:02:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2014-03-27 12:49:48 +00:00
|
|
|
$view = new \OC_FilesystemView('');
|
|
|
|
$util = new Util($view, $userId);
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2014-03-27 12:49:48 +00:00
|
|
|
// for write operation we always encrypt the files, for read operations
|
|
|
|
// we check if the existing file is encrypted or not decide if it needs to
|
|
|
|
// decrypt it.
|
|
|
|
if (($mode !== 'r' && $mode !== 'rb') || $util->isEncryptedPath($path)) {
|
2011-11-24 00:44:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2012-07-11 16:51:27 +00:00
|
|
|
return false;
|
2011-11-24 00:44:54 +00:00
|
|
|
}
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
/**
|
|
|
|
* @param $path
|
|
|
|
* @param $data
|
|
|
|
* @return bool
|
|
|
|
*/
|
2013-05-27 15:26:58 +00:00
|
|
|
public function preFile_put_contents($path, &$data) {
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-27 15:26:58 +00:00
|
|
|
if (self::shouldEncrypt($path)) {
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-27 15:26:58 +00:00
|
|
|
if (!is_resource($data)) {
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// get root view
|
2013-05-27 15:26:58 +00:00
|
|
|
$view = new \OC_FilesystemView('/');
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// get relative path
|
|
|
|
$relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
if (!isset($relativePath)) {
|
|
|
|
return true;
|
2013-05-15 22:31:17 +00:00
|
|
|
}
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-11-14 16:32:21 +00:00
|
|
|
// create random cache folder
|
|
|
|
$cacheFolder = rand();
|
|
|
|
$path_slices = explode('/', \OC_Filesystem::normalizePath($path));
|
|
|
|
$path_slices[2] = "cache/".$cacheFolder;
|
|
|
|
$tmpPath = implode('/', $path_slices);
|
|
|
|
|
|
|
|
$handle = fopen('crypt://' . $tmpPath, 'w');
|
2013-05-29 23:13:22 +00:00
|
|
|
if (is_resource($handle)) {
|
2013-04-25 13:20:06 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// write data to stream
|
|
|
|
fwrite($handle, $data);
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// close stream
|
|
|
|
fclose($handle);
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// disable encryption proxy to prevent recursive calls
|
|
|
|
$proxyStatus = \OC_FileProxy::$enabled;
|
|
|
|
\OC_FileProxy::$enabled = false;
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// get encrypted content
|
2013-11-14 16:32:21 +00:00
|
|
|
$data = $view->file_get_contents($tmpPath);
|
2013-04-18 13:42:28 +00:00
|
|
|
|
2014-01-23 14:45:34 +00:00
|
|
|
// store new unenecrypted size so that it can be updated
|
|
|
|
// in the post proxy
|
2013-12-16 14:24:11 +00:00
|
|
|
$tmpFileInfo = $view->getFileInfo($tmpPath);
|
2014-01-23 14:45:34 +00:00
|
|
|
if ( isset($tmpFileInfo['size']) ) {
|
|
|
|
self::$unencryptedSizes[\OC_Filesystem::normalizePath($path)] = $tmpFileInfo['size'];
|
|
|
|
}
|
2013-12-16 14:24:11 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// remove our temp file
|
2013-11-14 16:32:21 +00:00
|
|
|
$view->deleteAll('/' . \OCP\User::getUser() . '/cache/' . $cacheFolder);
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// re-enable proxy - our work is done
|
|
|
|
\OC_FileProxy::$enabled = $proxyStatus;
|
2014-03-28 11:02:49 +00:00
|
|
|
} else {
|
|
|
|
return false;
|
2013-05-29 23:13:22 +00:00
|
|
|
}
|
2011-10-21 15:02:11 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-09 16:09:20 +00:00
|
|
|
return true;
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-09 16:09:20 +00:00
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2014-01-23 14:45:34 +00:00
|
|
|
/**
|
|
|
|
* @brief update file cache with the new unencrypted size after file was written
|
|
|
|
* @param string $path
|
|
|
|
* @param mixed $result
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function postFile_put_contents($path, $result) {
|
|
|
|
$normalizedPath = \OC_Filesystem::normalizePath($path);
|
|
|
|
if ( isset(self::$unencryptedSizes[$normalizedPath]) ) {
|
|
|
|
$view = new \OC_FilesystemView('/');
|
|
|
|
$view->putFileInfo($normalizedPath,
|
2014-02-27 18:50:16 +00:00
|
|
|
array('encrypted' => true, 'unencrypted_size' => self::$unencryptedSizes[$normalizedPath]));
|
2014-01-23 14:45:34 +00:00
|
|
|
unset(self::$unencryptedSizes[$normalizedPath]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2012-12-11 15:10:56 +00:00
|
|
|
/**
|
|
|
|
* @param string $path Path of file from which has been read
|
|
|
|
* @param string $data Data that has been read from file
|
|
|
|
*/
|
2013-05-27 15:26:58 +00:00
|
|
|
public function postFile_get_contents($path, $data) {
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
$plainData = null;
|
2013-05-27 15:26:58 +00:00
|
|
|
$view = new \OC_FilesystemView('/');
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-21 22:53:07 +00:00
|
|
|
// init session
|
2013-05-29 07:21:00 +00:00
|
|
|
$session = new \OCA\Encryption\Session($view);
|
2013-05-21 22:53:07 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
// If data is a catfile
|
|
|
|
if (
|
2013-05-27 18:44:38 +00:00
|
|
|
Crypt::mode() === 'server'
|
2013-05-27 15:26:58 +00:00
|
|
|
&& Crypt::isCatfileContent($data)
|
2012-11-28 18:39:19 +00:00
|
|
|
) {
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-07-30 08:14:17 +00:00
|
|
|
$handle = fopen('crypt://' . $path, 'r');
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
if (is_resource($handle)) {
|
|
|
|
while (($plainDataChunk = fgets($handle, 8192)) !== false) {
|
|
|
|
$plainData .= $plainDataChunk;
|
|
|
|
}
|
|
|
|
}
|
2012-12-11 15:10:56 +00:00
|
|
|
|
2012-11-28 18:39:19 +00:00
|
|
|
} elseif (
|
2013-05-19 23:24:36 +00:00
|
|
|
Crypt::mode() == 'server'
|
2013-05-29 07:21:00 +00:00
|
|
|
&& \OC::$session->exists('legacyenckey')
|
2013-05-27 15:26:58 +00:00
|
|
|
&& Crypt::isEncryptedMeta($path)
|
2012-11-28 18:39:19 +00:00
|
|
|
) {
|
2013-05-29 23:13:22 +00:00
|
|
|
// Disable encryption proxy to prevent recursive calls
|
|
|
|
$proxyStatus = \OC_FileProxy::$enabled;
|
|
|
|
\OC_FileProxy::$enabled = false;
|
|
|
|
|
2013-05-27 16:09:35 +00:00
|
|
|
$plainData = Crypt::legacyBlockDecrypt($data, $session->getLegacyKey());
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
\OC_FileProxy::$enabled = $proxyStatus;
|
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-27 15:26:58 +00:00
|
|
|
if (!isset($plainData)) {
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-02-11 10:21:23 +00:00
|
|
|
$plainData = $data;
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2012-12-11 15:10:56 +00:00
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-02-11 10:21:23 +00:00
|
|
|
return $plainData;
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2011-10-21 15:02:11 +00:00
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2014-02-27 12:58:51 +00:00
|
|
|
/**
|
|
|
|
* @brief remember initial fopen mode because sometimes it gets changed during the request
|
|
|
|
* @param string $path path
|
|
|
|
* @param string $mode type of access
|
|
|
|
*/
|
|
|
|
public function preFopen($path, $mode) {
|
2014-03-27 12:49:48 +00:00
|
|
|
|
2014-02-27 12:58:51 +00:00
|
|
|
self::$fopenMode[$path] = $mode;
|
2014-03-27 12:49:48 +00:00
|
|
|
self::$enableEncryption = self::shouldEncrypt($path, $mode);
|
|
|
|
|
2014-02-27 12:58:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
/**
|
|
|
|
* @param $path
|
|
|
|
* @param $result
|
|
|
|
* @return resource
|
|
|
|
*/
|
2013-05-27 15:26:58 +00:00
|
|
|
public function postFopen($path, &$result) {
|
2013-04-25 20:49:47 +00:00
|
|
|
|
2013-05-30 23:57:32 +00:00
|
|
|
$path = \OC\Files\Filesystem::normalizePath($path);
|
|
|
|
|
2014-03-27 12:49:48 +00:00
|
|
|
if (!$result || self::$enableEncryption === false) {
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2011-11-24 00:44:54 +00:00
|
|
|
return $result;
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2011-11-24 00:44:54 +00:00
|
|
|
}
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2014-02-27 12:58:51 +00:00
|
|
|
// if we remember the mode from the pre proxy we re-use it
|
2014-03-27 12:49:48 +00:00
|
|
|
// otherwise we fall back to stream_get_meta_data()
|
2014-02-27 12:58:51 +00:00
|
|
|
if (isset(self::$fopenMode[$path])) {
|
|
|
|
$mode = self::$fopenMode[$path];
|
|
|
|
unset(self::$fopenMode[$path]);
|
|
|
|
} else {
|
|
|
|
$meta = stream_get_meta_data($result);
|
|
|
|
$mode = $meta['mode'];
|
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2014-03-27 12:49:48 +00:00
|
|
|
// Close the original encrypted file
|
|
|
|
fclose($result);
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2014-03-27 12:49:48 +00:00
|
|
|
// Open the file using the crypto stream wrapper
|
|
|
|
// protocol and let it do the decryption work instead
|
|
|
|
$result = fopen('crypt://' . $path, $mode);
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2011-11-24 00:44:54 +00:00
|
|
|
return $result;
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2011-10-21 15:02:11 +00:00
|
|
|
}
|
2012-02-15 20:44:58 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
/**
|
|
|
|
* @param $path
|
|
|
|
* @param $data
|
|
|
|
* @return array
|
|
|
|
*/
|
2013-05-27 15:26:58 +00:00
|
|
|
public function postGetFileInfo($path, $data) {
|
2013-04-25 20:49:47 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
// if path is a folder do nothing
|
2014-01-17 13:38:14 +00:00
|
|
|
if (\OCP\App::isEnabled('files_encryption') && $data !== false && array_key_exists('size', $data)) {
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
// Disable encryption proxy to prevent recursive calls
|
|
|
|
$proxyStatus = \OC_FileProxy::$enabled;
|
|
|
|
\OC_FileProxy::$enabled = false;
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
// get file size
|
2013-05-27 15:26:58 +00:00
|
|
|
$data['size'] = self::postFileSize($path, $data['size']);
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
// Re-enable the proxy
|
|
|
|
\OC_FileProxy::$enabled = $proxyStatus;
|
|
|
|
}
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
return $data;
|
|
|
|
}
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
/**
|
|
|
|
* @param $path
|
|
|
|
* @param $size
|
|
|
|
* @return bool
|
|
|
|
*/
|
2013-05-27 15:26:58 +00:00
|
|
|
public function postFileSize($path, $size) {
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-05-27 15:26:58 +00:00
|
|
|
$view = new \OC_FilesystemView('/');
|
2013-04-23 17:08:52 +00:00
|
|
|
|
2013-11-20 17:10:56 +00:00
|
|
|
$userId = Helper::getUser($path);
|
2013-10-14 14:34:14 +00:00
|
|
|
$util = new Util($view, $userId);
|
|
|
|
|
|
|
|
// if encryption is no longer enabled or if the files aren't migrated yet
|
|
|
|
// we return the default file size
|
|
|
|
if(!\OCP\App::isEnabled('files_encryption') ||
|
|
|
|
$util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) {
|
|
|
|
return $size;
|
|
|
|
}
|
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
// if path is a folder do nothing
|
2013-05-27 15:26:58 +00:00
|
|
|
if ($view->is_dir($path)) {
|
2014-03-07 10:25:29 +00:00
|
|
|
$proxyState = \OC_FileProxy::$enabled;
|
|
|
|
\OC_FileProxy::$enabled = false;
|
|
|
|
$fileInfo = $view->getFileInfo($path);
|
|
|
|
\OC_FileProxy::$enabled = $proxyState;
|
2014-03-10 16:25:16 +00:00
|
|
|
if (isset($fileInfo['unencrypted_size']) && $fileInfo['unencrypted_size'] > 0) {
|
2014-03-07 10:25:29 +00:00
|
|
|
return $fileInfo['unencrypted_size'];
|
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
return $size;
|
|
|
|
}
|
2013-04-22 02:40:49 +00:00
|
|
|
|
2013-05-29 23:13:22 +00:00
|
|
|
// get relative path
|
|
|
|
$relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
|
2013-05-07 11:42:08 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
// if path is empty we cannot resolve anything
|
2013-05-29 23:13:22 +00:00
|
|
|
if (empty($relativePath)) {
|
2013-05-19 23:24:36 +00:00
|
|
|
return $size;
|
|
|
|
}
|
2013-04-22 02:40:49 +00:00
|
|
|
|
2013-05-21 19:09:25 +00:00
|
|
|
$fileInfo = false;
|
|
|
|
// get file info from database/cache if not .part file
|
2013-11-12 09:24:10 +00:00
|
|
|
if (!Helper::isPartialFilePath($path)) {
|
2013-11-20 15:20:21 +00:00
|
|
|
$proxyState = \OC_FileProxy::$enabled;
|
|
|
|
\OC_FileProxy::$enabled = false;
|
2013-05-27 15:26:58 +00:00
|
|
|
$fileInfo = $view->getFileInfo($path);
|
2013-11-20 15:20:21 +00:00
|
|
|
\OC_FileProxy::$enabled = $proxyState;
|
2013-05-21 19:09:25 +00:00
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
|
|
|
// if file is encrypted return real file size
|
2014-01-17 11:56:17 +00:00
|
|
|
if ($fileInfo && $fileInfo['encrypted'] === true) {
|
2013-10-14 14:34:14 +00:00
|
|
|
// try to fix unencrypted file size if it doesn't look plausible
|
2013-10-16 09:24:56 +00:00
|
|
|
if ((int)$fileInfo['size'] > 0 && (int)$fileInfo['unencrypted_size'] === 0 ) {
|
2013-10-14 14:34:14 +00:00
|
|
|
$fixSize = $util->getFileSize($path);
|
|
|
|
$fileInfo['unencrypted_size'] = $fixSize;
|
|
|
|
// put file info if not .part file
|
2013-11-12 09:24:10 +00:00
|
|
|
if (!Helper::isPartialFilePath($relativePath)) {
|
2013-10-14 14:34:14 +00:00
|
|
|
$view->putFileInfo($path, $fileInfo);
|
|
|
|
}
|
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
$size = $fileInfo['unencrypted_size'];
|
|
|
|
} else {
|
|
|
|
// self healing if file was removed from file cache
|
2014-01-17 13:38:14 +00:00
|
|
|
if (!$fileInfo) {
|
2013-05-21 19:09:25 +00:00
|
|
|
$fileInfo = array();
|
|
|
|
}
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-27 15:26:58 +00:00
|
|
|
$fixSize = $util->getFileSize($path);
|
|
|
|
if ($fixSize > 0) {
|
2013-05-21 19:09:25 +00:00
|
|
|
$size = $fixSize;
|
2013-05-19 23:24:36 +00:00
|
|
|
|
2013-05-21 19:09:25 +00:00
|
|
|
$fileInfo['encrypted'] = true;
|
|
|
|
$fileInfo['unencrypted_size'] = $size;
|
|
|
|
|
|
|
|
// put file info if not .part file
|
2013-11-12 09:24:10 +00:00
|
|
|
if (!Helper::isPartialFilePath($relativePath)) {
|
2013-05-27 15:26:58 +00:00
|
|
|
$view->putFileInfo($path, $fileInfo);
|
2013-05-19 23:24:36 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-21 19:09:25 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
}
|
|
|
|
return $size;
|
|
|
|
}
|
2013-04-30 18:44:42 +00:00
|
|
|
|
2013-05-19 23:24:36 +00:00
|
|
|
}
|