From ff4b0c4d7f6b422c9426205897c015b497429b03 Mon Sep 17 00:00:00 2001
From: Michael Gapczynski <GapczynskiM@gmail.com>
Date: Sun, 1 Apr 2012 13:30:41 -0400
Subject: [PATCH] Move writable check into local filestorage so shared files
 can be renamed

---
 lib/filestorage/local.php | 4 ++++
 lib/filesystemview.php    | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 688501aee9..bd757f52ce 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -86,6 +86,10 @@ class OC_Filestorage_Local extends OC_Filestorage{
 		return $this->delTree($path);
 	}
 	public function rename($path1,$path2){
+		if (!$this->is_writable($path1)) {
+			OC_Log::write('core','unable to rename, file is not writable : '.$path1,OC_Log::ERROR);
+			return false;
+		}
 		if(! $this->file_exists($path1)){
 			OC_Log::write('core','unable to rename, file does not exists : '.$path1,OC_Log::ERROR);
 			return false;
diff --git a/lib/filesystemview.php b/lib/filesystemview.php
index a3736f1976..9d530c7ad6 100644
--- a/lib/filesystemview.php
+++ b/lib/filesystemview.php
@@ -192,7 +192,7 @@ class OC_FilesystemView {
 		return $this->basicOperation('unlink',$path,array('delete'));
 	}
 	public function rename($path1,$path2){
-		if(OC_FileProxy::runPreProxies('rename',$path1,$path2) and $this->is_writable($path1) and OC_Filesystem::isValidPath($path2)){
+		if(OC_FileProxy::runPreProxies('rename',$path1,$path2) and OC_Filesystem::isValidPath($path2)){
 			$run=true;
 			OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, array( OC_Filesystem::signal_param_oldpath => $path1 , OC_Filesystem::signal_param_newpath=>$path2, OC_Filesystem::signal_param_run => &$run));
 			if($run){
-- 
GitLab