diff options
author | Robin Appelman <robin@icewind.nl> | 2020-01-13 17:49:18 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-01-13 17:49:18 +0300 |
commit | c0eae29251f983346b2f49a6ebf14010e8c86be6 (patch) | |
tree | ecc048337f6216775bcdee293f3d6b295820a981 /lib | |
parent | 31d6b887c892f60ba35919760e4feed775bb95ed (diff) |
fix hooks not triggering when saving document
this fixes, among other things, versions not being created
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Document/DocumentStore.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Document/DocumentStore.php b/lib/Document/DocumentStore.php index 23c49da..9dd6174 100644 --- a/lib/Document/DocumentStore.php +++ b/lib/Document/DocumentStore.php @@ -21,6 +21,7 @@ namespace OCA\DocumentServer\Document; +use OC\Files\Filesystem; use OCP\Files\File; use OCA\DocumentServer\DocumentConverter; use OCP\Files\Folder; @@ -159,6 +160,7 @@ class DocumentStore { } $targetExtension = $sourceFile->getExtension(); + $storage = $sourceFile->getStorage(); $localPath = $this->getLocalPath($docFolder); @@ -166,6 +168,14 @@ class DocumentStore { $this->documentConverter->saveChanges($localPath, $changes, $target, $targetExtension); $savedContent = fopen($target, 'r'); + if (!Filesystem::$loaded) { + // the filesystem needs to be initialized for a user in order for hooks to trigger + // just the `getUserFolder` is not enough for this + [, $user] = explode('/', $sourceFile->getPath()); + $userDir = '/' . $user . '/files'; + Filesystem::init($user, $userDir); + } + $sourceFile->putContent(stream_get_contents($savedContent)); } |