Advertisement
Guest User

Untitled

a guest
May 10th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 2.30 KB | None | 0 0
  1. From 37e94480d4ebd94057d37ed1a043c482cb140d51 Mon Sep 17 00:00:00 2001
  2. From: Olivier Goffart <ogoffart@woboq.com>
  3. Date: Thu, 22 Nov 2012 14:24:14 +0100
  4. Subject: [PATCH] Hack to get moving works from one directory to another
  5.  
  6. this enable DAV  to call rename even when moving between directory
  7.  
  8. WARNING: does need the backend to support it
  9. ---
  10. 3rdparty/Sabre/DAV/Tree.php  | 11 +++++++----
  11.  lib/connector/sabre/node.php | 12 ++++++++++++
  12.  2 files changed, 19 insertions(+), 4 deletions(-)
  13.  
  14. diff --git a/3rdparty/Sabre/DAV/Tree.php b/3rdparty/Sabre/DAV/Tree.php
  15. index 5021639..1b04726 100755
  16. --- a/3rdparty/Sabre/DAV/Tree.php
  17. +++ b/3rdparty/Sabre/DAV/Tree.php
  18. @@ -78,12 +78,15 @@ abstract class Sabre_DAV_Tree {
  19.          list($sourceDir, $sourceName) = Sabre_DAV_URLUtil::splitPath($sourcePath);
  20.          list($destinationDir, $destinationName) = Sabre_DAV_URLUtil::splitPath($destinationPath);
  21.  
  22. +   $renameable = $this->getNodeForPath($sourcePath);
  23. +
  24.          if ($sourceDir===$destinationDir) {
  25. -            $renameable = $this->getNodeForPath($sourcePath);
  26. -            $renameable->setName($destinationName);
  27. -        } else {
  28. +            $renameable->setName($destinationPath);
  29. +   } else if ($renameable instanceof OC_Connector_Sabre_Node) {
  30. +           $renameable->move($destinationPath);
  31. +   } else {
  32.              $this->copy($sourcePath,$destinationPath);
  33. -            $this->getNodeForPath($sourcePath)->delete();
  34. +            $renameable->delete();
  35.          }
  36.          $this->markDirty($sourceDir);
  37.          $this->markDirty($destinationDir);
  38. diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
  39. index ba1788c..1ae3176 100644
  40. --- a/lib/connector/sabre/node.php
  41. +++ b/lib/connector/sabre/node.php
  42. @@ -97,6 +97,18 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
  43.  
  44.     }
  45.  
  46. +   public function move($newPath) {
  47. +       $oldPath = $this->path;
  48. +
  49. +       OC_Filesystem::rename($this->path,$newPath);
  50. +
  51. +       $this->path = $newPath;
  52. +
  53. +       $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertypath` = ? WHERE `userid` = ? AND `propertypath` = ?' );
  54. +       $query->execute( array( $newPath,OC_User::getUser(), $oldPath ));
  55. +
  56. +   }
  57. +
  58.     public function setFileinfoCache($fileinfo_cache)
  59.     {
  60.         $this->fileinfo_cache = $fileinfo_cache;
  61. --
  62. 1.7.12.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement