mirror of
https://github.com/nextcloud/server.git
synced 2024-08-10 14:11:53 +02:00
Manually triger the filecache update hooks before any other hook
This commit is contained in:
parent
59df3ffdf4
commit
bc49c6be04
@ -12,13 +12,6 @@ OCP\App::addNavigationEntry(array("id" => "files_index",
|
|||||||
|
|
||||||
OC_Search::registerProvider('OC_Search_Provider_File');
|
OC_Search::registerProvider('OC_Search_Provider_File');
|
||||||
|
|
||||||
// cache hooks must be connected before all other apps.
|
|
||||||
// since 'files' is always loaded first the hooks need to be connected here
|
|
||||||
\OC_Hook::connect('OC_Filesystem', 'post_write', '\OC\Files\Cache\Updater', 'writeHook');
|
|
||||||
\OC_Hook::connect('OC_Filesystem', 'post_touch', '\OC\Files\Cache\Updater', 'touchHook');
|
|
||||||
\OC_Hook::connect('OC_Filesystem', 'post_delete', '\OC\Files\Cache\Updater', 'deleteHook');
|
|
||||||
\OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Updater', 'renameHook');
|
|
||||||
|
|
||||||
\OCP\BackgroundJob::addRegularTask('\OC\Files\Cache\BackgroundWatcher', 'checkNext');
|
\OCP\BackgroundJob::addRegularTask('\OC\Files\Cache\BackgroundWatcher', 'checkNext');
|
||||||
|
|
||||||
$templateManager = OC_Helper::getFileTemplateManager();
|
$templateManager = OC_Helper::getFileTemplateManager();
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
namespace OC\Files;
|
namespace OC\Files;
|
||||||
|
|
||||||
|
use OC\Files\Cache\Updater;
|
||||||
|
|
||||||
class View {
|
class View {
|
||||||
private $fakeRoot = '';
|
private $fakeRoot = '';
|
||||||
private $internal_path_cache = array();
|
private $internal_path_cache = array();
|
||||||
@ -433,6 +435,7 @@ class View {
|
|||||||
}
|
}
|
||||||
if ($this->shouldEmitHooks() && (Cache\Scanner::isPartialFile($path1) && !Cache\Scanner::isPartialFile($path2)) && $result !== false) {
|
if ($this->shouldEmitHooks() && (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
|
// 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)));
|
||||||
\OC_Hook::emit(
|
\OC_Hook::emit(
|
||||||
Filesystem::CLASSNAME,
|
Filesystem::CLASSNAME,
|
||||||
Filesystem::signal_post_write,
|
Filesystem::signal_post_write,
|
||||||
@ -441,6 +444,10 @@ class View {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
} elseif ($this->shouldEmitHooks() && $result !== false) {
|
} elseif ($this->shouldEmitHooks() && $result !== false) {
|
||||||
|
Updater::renameHook(array(
|
||||||
|
'oldpath' => $this->getHookPath($path1),
|
||||||
|
'newpath' => $this->getHookPath($path2)
|
||||||
|
));
|
||||||
\OC_Hook::emit(
|
\OC_Hook::emit(
|
||||||
Filesystem::CLASSNAME,
|
Filesystem::CLASSNAME,
|
||||||
Filesystem::signal_post_rename,
|
Filesystem::signal_post_rename,
|
||||||
@ -741,7 +748,10 @@ class View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param string[] $hooks
|
||||||
* @param string $path
|
* @param string $path
|
||||||
|
* @param bool $post
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function runHooks($hooks, $path, $post = false) {
|
private function runHooks($hooks, $path, $post = false) {
|
||||||
$path = $this->getHookPath($path);
|
$path = $this->getHookPath($path);
|
||||||
@ -749,6 +759,16 @@ class View {
|
|||||||
$run = true;
|
$run = true;
|
||||||
if ($this->shouldEmitHooks($path)) {
|
if ($this->shouldEmitHooks($path)) {
|
||||||
foreach ($hooks as $hook) {
|
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') {
|
if ($hook != 'read') {
|
||||||
\OC_Hook::emit(
|
\OC_Hook::emit(
|
||||||
Filesystem::CLASSNAME,
|
Filesystem::CLASSNAME,
|
||||||
|
5
tests/lib/files/cache/updater.php
vendored
5
tests/lib/files/cache/updater.php
vendored
@ -65,11 +65,6 @@ class Updater extends \PHPUnit_Framework_TestCase {
|
|||||||
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
|
Filesystem::mount($this->storage, array(), '/' . self::$user . '/files');
|
||||||
|
|
||||||
\OC_Hook::clear('OC_Filesystem');
|
\OC_Hook::clear('OC_Filesystem');
|
||||||
|
|
||||||
\OC_Hook::connect('OC_Filesystem', 'post_write', '\OC\Files\Cache\Updater', 'writeHook');
|
|
||||||
\OC_Hook::connect('OC_Filesystem', 'post_delete', '\OC\Files\Cache\Updater', 'deleteHook');
|
|
||||||
\OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Updater', 'renameHook');
|
|
||||||
\OC_Hook::connect('OC_Filesystem', 'post_touch', '\OC\Files\Cache\Updater', 'touchHook');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
Loading…
Reference in New Issue
Block a user