summaryrefslogtreecommitdiffstats
path: root/lib/private/connector/sabre/file.php
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-05-12 19:08:04 +0200
committerVincent Petry <pvince81@owncloud.com>2015-05-13 17:47:04 +0200
commit3cae0135adfc61fd8cbecb5932853cf5c56a324b (patch)
tree753d2f618a0ce90744fef55bb2cdf5207a7b3483 /lib/private/connector/sabre/file.php
parentdc362823e0d30b80be1ead90ef6d4ddb76fd1929 (diff)
downloadnextcloud-server-3cae0135adfc61fd8cbecb5932853cf5c56a324b.tar.gz
nextcloud-server-3cae0135adfc61fd8cbecb5932853cf5c56a324b.zip
Fire prehooks when uploading directly to storage
Diffstat (limited to 'lib/private/connector/sabre/file.php')
-rw-r--r--lib/private/connector/sabre/file.php34
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(