/** * 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); } } }