diff options
Diffstat (limited to 'lib/private/files/view.php')
-rw-r--r-- | lib/private/files/view.php | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index f97f846bb5a..95f3e9a2c7f 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -31,8 +31,14 @@ use OC\Files\Mount\MoveableMount; class View { private $fakeRoot = ''; + /** + * @var \OC\Files\Cache\Updater + */ + protected $updater; + public function __construct($root = '') { $this->fakeRoot = $root; + $this->updater = new Updater($this); } public function getAbsolutePath($path = '/') { @@ -168,10 +174,10 @@ class View { * @param string $path relative to data/ * @return boolean */ - protected function removeMount($mount, $path){ + protected function removeMount($mount, $path) { if ($mount instanceof MoveableMount) { // cut of /user/files to get the relative path to data/user/files - $pathParts= explode('/', $path, 4); + $pathParts = explode('/', $path, 4); $relPath = '/' . $pathParts[3]; \OC_Hook::emit( Filesystem::CLASSNAME, "umount", @@ -194,7 +200,7 @@ class View { } public function rmdir($path) { - $absolutePath= $this->getAbsolutePath($path); + $absolutePath = $this->getAbsolutePath($path); $mount = Filesystem::getMountManager()->find($absolutePath); if ($mount->getInternalPath($absolutePath) === '') { return $this->removeMount($mount, $path); @@ -310,6 +316,9 @@ class View { if(!$this->file_exists($path)){ return false; } + if (is_null($mtime)) { + $mtime = time(); + } //if native touch fails, we emulate it by changing the mtime in the cache $this->putFileInfo($path, array('mtime' => $mtime)); } @@ -374,10 +383,8 @@ class View { list ($count, $result) = \OC_Helper::streamCopy($data, $target); fclose($target); fclose($data); + $this->updater->update($path); if ($this->shouldEmitHooks($path) && $result !== false) { - Updater::writeHook(array( - 'path' => $this->getHookPath($path) - )); $this->emit_file_hooks_post($exists, $path); } \OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count); @@ -402,7 +409,7 @@ class View { $postFix = (substr($path, -1, 1) === '/') ? '/' : ''; $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); $mount = Filesystem::getMountManager()->find($absolutePath . $postFix); - if ($mount->getInternalPath($absolutePath) === '') { + if ($mount and $mount->getInternalPath($absolutePath) === '') { return $this->removeMount($mount, $absolutePath); } return $this->basicOperation('unlink', $path, array('delete')); @@ -495,15 +502,14 @@ class View { } } } - if ($this->shouldEmitHooks() && (Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2)) && $result !== false) { + if ((Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2)) && $result !== false) { // if it was a rename from a part file to a regular file it was a write and not a rename operation - Updater::writeHook(array('path' => $this->getHookPath($path2))); - $this->emit_file_hooks_post($exists, $path2); + $this->updater->update($path2); + if ($this->shouldEmitHooks()) { + $this->emit_file_hooks_post($exists, $path2); + } } elseif ($this->shouldEmitHooks() && $result !== false) { - Updater::renameHook(array( - 'oldpath' => $this->getHookPath($path1), - 'newpath' => $this->getHookPath($path2) - )); + $this->updater->rename($path1, $path2); \OC_Hook::emit( Filesystem::CLASSNAME, Filesystem::signal_post_rename, @@ -582,6 +588,7 @@ class View { fclose($target); } } + $this->updater->update($path2); if ($this->shouldEmitHooks() && $result !== false) { \OC_Hook::emit( Filesystem::CLASSNAME, @@ -760,7 +767,19 @@ class View { } else { $result = $storage->$operation($internalPath); } + $result = \OC_FileProxy::runPostProxies($operation, $this->getAbsolutePath($path), $result); + + if (in_array('delete', $hooks)) { + $this->updater->remove($path); + } + if (in_array('write', $hooks)) { + $this->updater->update($path); + } + if (in_array('touch', $hooks)) { + $this->updater->update($path, $extraParam); + } + if ($this->shouldEmitHooks($path) && $result !== false) { if ($operation != 'fopen') { //no post hooks for fopen, the file stream is still open $this->runHooks($hooks, $path, true); @@ -814,16 +833,6 @@ class View { $run = true; if ($this->shouldEmitHooks($path)) { foreach ($hooks as $hook) { - // manually triger updater hooks to ensure they are called first - if ($post) { - if ($hook == 'write') { - Updater::writeHook(array('path' => $path)); - } elseif ($hook == 'touch') { - Updater::touchHook(array('path' => $path)); - } else if ($hook == 'delete') { - Updater::deleteHook(array('path' => $path)); - } - } if ($hook != 'read') { \OC_Hook::emit( Filesystem::CLASSNAME, |