Beispiel #1
0
 private static function preRenameOrCopy($params, $operation)
 {
     $user = \OCP\User::getUser();
     $view = new \OC\Files\View('/');
     $util = new Util($view, $user);
     // we only need to rename the keys if the rename happens on the same mountpoint
     // otherwise we perform a stream copy, so we get a new set of keys
     $oldPath = \OC\Files\Filesystem::normalizePath('/' . $user . '/files/' . $params['oldpath']);
     $newPath = \OC\Files\Filesystem::normalizePath('/' . $user . '/files/' . $params['newpath']);
     $mp1 = $view->getMountPoint($oldPath);
     $mp2 = $view->getMountPoint($newPath);
     $oldKeysPath = Keymanager::getKeyPath($view, $util, $params['oldpath']);
     if ($mp1 === $mp2) {
         self::$renamedFiles[$params['oldpath']] = array('operation' => $operation, 'oldKeysPath' => $oldKeysPath);
     } elseif ($mp1 !== $oldPath . '/') {
         self::$renamedFiles[$params['oldpath']] = array('operation' => 'cleanup', 'oldKeysPath' => $oldKeysPath);
     }
 }
Beispiel #2
0
 /**
  * mark file as renamed so that we know the original source after the file was renamed
  * @param array $params with the old path and the new path
  */
 public static function preCopy($params)
 {
     $user = \OCP\User::getUser();
     $view = new \OC\Files\View('/');
     $util = new Util($view, $user);
     list($ownerOld, $pathOld) = $util->getUidAndFilename($params['oldpath']);
     // we only need to rename the keys if the rename happens on the same mountpoint
     // otherwise we perform a stream copy, so we get a new set of keys
     $mp1 = $view->getMountPoint('/' . $user . '/files/' . $params['oldpath']);
     $mp2 = $view->getMountPoint('/' . $user . '/files/' . $params['newpath']);
     $type = $view->is_dir('/' . $user . '/files/' . $params['oldpath']) ? 'folder' : 'file';
     if ($mp1 === $mp2) {
         self::$renamedFiles[$params['oldpath']] = array('uid' => $ownerOld, 'path' => $pathOld, 'type' => $type, 'operation' => 'copy');
     }
 }
Beispiel #3
0
 private static function preRenameOrCopy($params, $operation)
 {
     $user = \OCP\User::getUser();
     $view = new \OC\Files\View('/');
     $util = new Util($view, $user);
     list($ownerOld, $pathOld) = $util->getUidAndFilename($params['oldpath']);
     // we only need to rename the keys if the rename happens on the same mountpoint
     // otherwise we perform a stream copy, so we get a new set of keys
     $mp1 = $view->getMountPoint('/' . $user . '/files/' . $params['oldpath']);
     $mp2 = $view->getMountPoint('/' . $user . '/files/' . $params['newpath']);
     $type = $view->is_dir('/' . $user . '/files/' . $params['oldpath']) ? 'folder' : 'file';
     if ($mp1 === $mp2) {
         if ($util->isSystemWideMountPoint($pathOld)) {
             $oldShareKeyPath = 'files_encryption/share-keys/' . $pathOld;
         } else {
             $oldShareKeyPath = $ownerOld . '/' . 'files_encryption/share-keys/' . $pathOld;
         }
         // gather share keys here because in postRename() the file will be moved already
         $oldShareKeys = Helper::findShareKeys($pathOld, $oldShareKeyPath, $view);
         if (count($oldShareKeys) === 0) {
             \OC_Log::write('Encryption library', 'No share keys found for "' . $pathOld . '"', \OC_Log::WARN);
         }
         self::$renamedFiles[$params['oldpath']] = array('uid' => $ownerOld, 'path' => $pathOld, 'type' => $type, 'operation' => $operation, 'sharekeys' => $oldShareKeys);
     }
 }