diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2015-05-15 15:08:27 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2015-05-15 15:08:27 +0200 |
commit | 0991c0cc02c10f74065010be9364e5c290a19753 (patch) | |
tree | ba315ef2ffe739b9386aa3595b0e82060b02c4d5 /lib/private/connector | |
parent | 03e26a0fbea3c96593ee7c533b9b303664e4d4f5 (diff) | |
parent | 3cae0135adfc61fd8cbecb5932853cf5c56a324b (diff) | |
download | nextcloud-server-0991c0cc02c10f74065010be9364e5c290a19753.tar.gz nextcloud-server-0991c0cc02c10f74065010be9364e5c290a19753.zip |
Merge pull request #16292 from owncloud/webdav-storage-fireprehooks
Fire prehooks when uploading directly to storage
Diffstat (limited to 'lib/private/connector')
-rw-r--r-- | lib/private/connector/sabre/file.php | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index cfa1cacdd0b..8e4460ef3b5 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -161,13 +161,37 @@ class File extends Node implements IFile { } try { + $view = \OC\Files\Filesystem::getView(); + $run = true; + if ($view) { + $hookPath = $view->getRelativePath($this->fileView->getAbsolutePath($this->path)); + + if (!$exists) { + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_create, array( + \OC\Files\Filesystem::signal_param_path => $hookPath, + \OC\Files\Filesystem::signal_param_run => &$run, + )); + } else { + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_update, array( + \OC\Files\Filesystem::signal_param_path => $hookPath, + \OC\Files\Filesystem::signal_param_run => &$run, + )); + } + \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_write, array( + \OC\Files\Filesystem::signal_param_path => $hookPath, + \OC\Files\Filesystem::signal_param_run => &$run, + )); + } + if ($needsPartFile) { // rename to correct path try { - $renameOkay = $storage->moveFromStorage($partStorage, $internalPartPath, $internalPath); - $fileExists = $storage->file_exists($internalPath); - if ($renameOkay === false || $fileExists === false) { - \OC_Log::write('webdav', '\OC\Files\Filesystem::rename() failed', \OC_Log::ERROR); + if ($run) { + $renameOkay = $storage->moveFromStorage($partStorage, $internalPartPath, $internalPath); + $fileExists = $storage->file_exists($internalPath); + } + if (!$run || $renameOkay === false || $fileExists === false) { + \OC_Log::write('webdav', 'renaming part file to final file failed', \OC_Log::ERROR); $partStorage->unlink($internalPartPath); throw new Exception('Could not rename part file to final file'); } @@ -180,9 +204,7 @@ class File extends Node implements IFile { // since we skipped the view we need to scan and emit the hooks ourselves $partStorage->getScanner()->scanFile($internalPath); - $view = \OC\Files\Filesystem::getView(); if ($view) { - $hookPath = $view->getRelativePath($this->fileView->getAbsolutePath($this->path)); $this->fileView->getUpdater()->propagate($hookPath); if (!$exists) { \OC_Hook::emit(\OC\Files\Filesystem::CLASSNAME, \OC\Files\Filesystem::signal_post_create, array( |