Skip to content

Commit 543c863

Browse files
authored
Merge pull request #11931 from nextcloud/bug/do_not_emit_pre_hooks_twice_objectstore
Do not emit preHooks twice on non-part-storage
2 parents 0b27487 + b51e503 commit 543c863

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

apps/dav/lib/Connector/Sabre/File.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,27 @@ public function put($data) {
140140
list($partStorage) = $this->fileView->resolvePath($this->path);
141141
$needsPartFile = $partStorage->needsPartFile() && (strlen($this->path) > 1);
142142

143+
$view = \OC\Files\Filesystem::getView();
144+
143145
if ($needsPartFile) {
144146
// mark file as partial while uploading (ignored by the scanner)
145147
$partFilePath = $this->getPartFileBasePath($this->path) . '.ocTransferId' . rand() . '.part';
146148
} else {
147149
// upload file directly as the final path
148150
$partFilePath = $this->path;
149151

150-
$this->emitPreHooks($exists);
152+
if ($view && !$this->emitPreHooks($exists)) {
153+
throw new Exception('Could not write to final file, canceled by hook');
154+
}
151155
}
152156

153-
$view = \OC\Files\Filesystem::getView();
154-
155157
// the part file and target file might be on a different storage in case of a single file storage (e.g. single file share)
156158
/** @var \OC\Files\Storage\Storage $partStorage */
157159
list($partStorage, $internalPartPath) = $this->fileView->resolvePath($partFilePath);
158160
/** @var \OC\Files\Storage\Storage $storage */
159161
list($storage, $internalPath) = $this->fileView->resolvePath($this->path);
160162
try {
161163
if (!$needsPartFile) {
162-
if ($view && !$this->emitPreHooks($exists)) {
163-
throw new Exception('Could not write to final file, canceled by hook');
164-
}
165164
$this->changeLock(ILockingProvider::LOCK_EXCLUSIVE);
166165
}
167166

0 commit comments

Comments
 (0)