dont trigger filesystem hooks when not using the default view

This commit is contained in:
Robin Appelman 2012-09-17 22:12:17 +02:00
parent 7749875a0d
commit 82ffefb99b
1 changed files with 84 additions and 72 deletions

View File

@ -263,6 +263,7 @@ class OC_FilesystemView {
$path = $this->getRelativePath($absolutePath); $path = $this->getRelativePath($absolutePath);
$exists = $this->file_exists($path); $exists = $this->file_exists($path);
$run = true; $run = true;
if( $this->fakeRoot==OC_Filesystem::getRoot() ){
if(!$exists) { if(!$exists) {
OC_Hook::emit( OC_Hook::emit(
OC_Filesystem::CLASSNAME, OC_Filesystem::CLASSNAME,
@ -281,6 +282,7 @@ class OC_FilesystemView {
OC_Filesystem::signal_param_run => &$run OC_Filesystem::signal_param_run => &$run
) )
); );
}
if(!$run) { if(!$run) {
return false; return false;
} }
@ -289,6 +291,7 @@ class OC_FilesystemView {
$count=OC_Helper::streamCopy($data, $target); $count=OC_Helper::streamCopy($data, $target);
fclose($target); fclose($target);
fclose($data); fclose($data);
if( $this->fakeRoot==OC_Filesystem::getRoot() ){
if(!$exists) { if(!$exists) {
OC_Hook::emit( OC_Hook::emit(
OC_Filesystem::CLASSNAME, OC_Filesystem::CLASSNAME,
@ -301,6 +304,7 @@ class OC_FilesystemView {
OC_Filesystem::signal_post_write, OC_Filesystem::signal_post_write,
array( OC_Filesystem::signal_param_path => $path) array( OC_Filesystem::signal_param_path => $path)
); );
}
OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count); OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
return $count > 0; return $count > 0;
}else{ }else{
@ -330,6 +334,7 @@ class OC_FilesystemView {
return false; return false;
} }
$run=true; $run=true;
if( $this->fakeRoot==OC_Filesystem::getRoot() ){
OC_Hook::emit( OC_Hook::emit(
OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename, OC_Filesystem::CLASSNAME, OC_Filesystem::signal_rename,
array( array(
@ -338,6 +343,7 @@ class OC_FilesystemView {
OC_Filesystem::signal_param_run => &$run OC_Filesystem::signal_param_run => &$run
) )
); );
}
if($run) { if($run) {
$mp1 = $this->getMountPoint($path1.$postFix1); $mp1 = $this->getMountPoint($path1.$postFix1);
$mp2 = $this->getMountPoint($path2.$postFix2); $mp2 = $this->getMountPoint($path2.$postFix2);
@ -353,6 +359,7 @@ class OC_FilesystemView {
$storage1->unlink($this->getInternalPath($path1.$postFix1)); $storage1->unlink($this->getInternalPath($path1.$postFix1));
$result = $count>0; $result = $count>0;
} }
if( $this->fakeRoot==OC_Filesystem::getRoot() ){
OC_Hook::emit( OC_Hook::emit(
OC_Filesystem::CLASSNAME, OC_Filesystem::CLASSNAME,
OC_Filesystem::signal_post_rename, OC_Filesystem::signal_post_rename,
@ -361,6 +368,7 @@ class OC_FilesystemView {
OC_Filesystem::signal_param_newpath => $path2 OC_Filesystem::signal_param_newpath => $path2
) )
); );
}
return $result; return $result;
} }
} }
@ -378,6 +386,7 @@ class OC_FilesystemView {
return false; return false;
} }
$run=true; $run=true;
if( $this->fakeRoot==OC_Filesystem::getRoot() ){
OC_Hook::emit( OC_Hook::emit(
OC_Filesystem::CLASSNAME, OC_Filesystem::CLASSNAME,
OC_Filesystem::signal_copy, OC_Filesystem::signal_copy,
@ -408,6 +417,7 @@ class OC_FilesystemView {
) )
); );
} }
}
if($run) { if($run) {
$mp1=$this->getMountPoint($path1.$postFix1); $mp1=$this->getMountPoint($path1.$postFix1);
$mp2=$this->getMountPoint($path2.$postFix2); $mp2=$this->getMountPoint($path2.$postFix2);
@ -420,6 +430,7 @@ class OC_FilesystemView {
$target = $this->fopen($path2.$postFix2, 'w'); $target = $this->fopen($path2.$postFix2, 'w');
$result = OC_Helper::streamCopy($source, $target); $result = OC_Helper::streamCopy($source, $target);
} }
if( $this->fakeRoot==OC_Filesystem::getRoot() ){
OC_Hook::emit( OC_Hook::emit(
OC_Filesystem::CLASSNAME, OC_Filesystem::CLASSNAME,
OC_Filesystem::signal_post_copy, OC_Filesystem::signal_post_copy,
@ -440,6 +451,7 @@ class OC_FilesystemView {
OC_Filesystem::signal_post_write, OC_Filesystem::signal_post_write,
array( OC_Filesystem::signal_param_path => $path2) array( OC_Filesystem::signal_param_path => $path2)
); );
}
return $result; return $result;
} }
} }