diff options
Diffstat (limited to 'apps/files_trashbin/lib/trashbin.php')
-rw-r--r-- | apps/files_trashbin/lib/trashbin.php | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 6bdbac49aa7..1c880735b5a 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -183,8 +183,6 @@ class Trashbin { $userTrashSize = self::getTrashbinSize($user); // disable proxy to prevent recursive calls - $proxyStatus = \OC_FileProxy::$enabled; - \OC_FileProxy::$enabled = false; $trashPath = '/files_trashbin/files/' . $filename . '.d' . $timestamp; try { $sizeOfAddedFiles = $view->filesize('/files/' . $file_path); @@ -199,7 +197,6 @@ class Trashbin { } \OC_Log::write('files_trashbin', 'Couldn\'t move ' . $file_path . ' to the trash bin', \OC_log::ERROR); } - \OC_FileProxy::$enabled = $proxyStatus; if ($view->file_exists('/files/' . $file_path)) { // failed to delete the original file, abort $view->unlink($trashPath); @@ -217,7 +214,6 @@ class Trashbin { 'trashPath' => \OC\Files\Filesystem::normalizePath($filename . '.d' . $timestamp))); $size += self::retainVersions($file_path, $filename, $timestamp); - $size += self::retainEncryptionKeys($file_path, $filename, $timestamp); // if owner !== user we need to also add a copy to the owners trash if ($user !== $owner) { @@ -251,10 +247,6 @@ class Trashbin { $size = 0; if (\OCP\App::isEnabled('files_versions')) { - // disable proxy to prevent recursive calls - $proxyStatus = \OC_FileProxy::$enabled; - \OC_FileProxy::$enabled = false; - $user = \OCP\User::getUser(); $rootView = new \OC\Files\View('/'); @@ -279,60 +271,12 @@ class Trashbin { $rootView->rename($owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp); } } - - // enable proxy - \OC_FileProxy::$enabled = $proxyStatus; } return $size; } /** - * Move encryption keys to trash so that they can be restored later - * - * @param string $file_path path to original file - * @param string $filename of deleted file - * @param integer $timestamp when the file was deleted - * - * @return int size of encryption keys - */ - private static function retainEncryptionKeys($file_path, $filename, $timestamp) { - $size = 0; - - if (\OCP\App::isEnabled('files_encryption')) { - - $user = \OCP\User::getUser(); - $rootView = new \OC\Files\View('/'); - - list($owner, $ownerPath) = self::getUidAndFilename($file_path); - - // file has been deleted in between - if (empty($ownerPath)) { - return 0; - } - - $util = new \OCA\Files_Encryption\Util($rootView, $user); - - $baseDir = '/files_encryption/'; - if (!$util->isSystemWideMountPoint($ownerPath)) { - $baseDir = $owner . $baseDir; - } - - $keyfiles = \OC\Files\Filesystem::normalizePath($baseDir . '/keys/' . $ownerPath); - - if ($rootView->is_dir($keyfiles)) { - $size += self::calculateSize(new \OC\Files\View($keyfiles)); - if ($owner !== $user) { - self::copy_recursive($keyfiles, $owner . '/files_trashbin/keys/' . basename($ownerPath) . '.d' . $timestamp, $rootView); - } - $rootView->rename($keyfiles, $user . '/files_trashbin/keys/' . $filename . '.d' . $timestamp); - } - - } - return $size; - } - - /** * restore files from trash bin * * @param string $file path to the deleted file @@ -369,10 +313,6 @@ class Trashbin { $target = \OC\Files\Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename); $mtime = $view->filemtime($source); - // disable proxy to prevent recursive calls - $proxyStatus = \OC_FileProxy::$enabled; - \OC_FileProxy::$enabled = false; - // restore file $restoreResult = $view->rename($source, $target); @@ -386,22 +326,15 @@ class Trashbin { 'trashPath' => \OC\Files\Filesystem::normalizePath($file))); self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp); - self::restoreEncryptionKeys($view, $file, $filename, $uniqueFilename, $location, $timestamp); if ($timestamp) { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_trash` WHERE `user`=? AND `id`=? AND `timestamp`=?'); $query->execute(array($user, $filename, $timestamp)); } - // enable proxy - \OC_FileProxy::$enabled = $proxyStatus; - return true; } - // enable proxy - \OC_FileProxy::$enabled = $proxyStatus; - return false; } @@ -419,9 +352,6 @@ class Trashbin { private static function restoreVersions(\OC\Files\View $view, $file, $filename, $uniqueFilename, $location, $timestamp) { if (\OCP\App::isEnabled('files_versions')) { - // disable proxy to prevent recursive calls - $proxyStatus = \OC_FileProxy::$enabled; - \OC_FileProxy::$enabled = false; $user = \OCP\User::getUser(); $rootView = new \OC\Files\View('/'); @@ -432,7 +362,6 @@ class Trashbin { // file has been deleted in between if (empty($ownerPath)) { - \OC_FileProxy::$enabled = $proxyStatus; return false; } @@ -453,63 +382,6 @@ class Trashbin { } } } - - // enable proxy - \OC_FileProxy::$enabled = $proxyStatus; - } - } - - /** - * restore encryption keys from trash bin - * - * @param \OC\Files\View $view - * @param string $file complete path to file - * @param string $filename name of file - * @param string $uniqueFilename new file name to restore the file without overwriting existing files - * @param string $location location of file - * @param int $timestamp deletion time - * @return bool - */ - private static function restoreEncryptionKeys(\OC\Files\View $view, $file, $filename, $uniqueFilename, $location, $timestamp) { - - if (\OCP\App::isEnabled('files_encryption')) { - $user = \OCP\User::getUser(); - $rootView = new \OC\Files\View('/'); - - $target = \OC\Files\Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename); - - list($owner, $ownerPath) = self::getUidAndFilename($target); - - // file has been deleted in between - if (empty($ownerPath)) { - return false; - } - - $util = new \OCA\Files_Encryption\Util($rootView, $user); - - $baseDir = '/files_encryption/'; - if (!$util->isSystemWideMountPoint($ownerPath)) { - $baseDir = $owner . $baseDir; - } - - $source_location = dirname($file); - - if ($view->is_dir('/files_trashbin/keys/' . $file)) { - if ($source_location != '.') { - $keyfile = \OC\Files\Filesystem::normalizePath($user . '/files_trashbin/keys/' . $source_location . '/' . $filename); - } else { - $keyfile = \OC\Files\Filesystem::normalizePath($user . '/files_trashbin/keys/' . $filename); - } - } - - if ($timestamp) { - $keyfile .= '.d' . $timestamp; - } - - if ($rootView->is_dir($keyfile)) { - $rootView->rename($keyfile, $baseDir . '/keys/' . $ownerPath); - } - } } @@ -528,7 +400,6 @@ class Trashbin { return true; } - /** * delete file from trash bin permanently * |